Skip to content

ARMI import order matters for runLog #2182

@alexhjames

Description

@alexhjames

When running tests with pytest, when armi is imported is important for whether pytest captures the stdout from the runLog. If armi is not imported until pytest_sessionstart hook, then the runLog will print all log statements to the screen as tests are executing instead of pytest capturing them and displaying them only for failed tests at the end of test execution. If armi is imported prior to that point, then the runLog statements are captured as expected and only displayed for failed tests.

This can be seen in the ARMI code base if the following steps are taken:

  1. Relocate conftest.py to the repository root level (this ensures that the __init__.py in the ARMI directory is not invoked during the process of invoking conftest.py)
  2. Move the import statements in conftest.py from the top of the file to be local to the function they are used in.
  3. Run armi tests with pytest . (don't parallel process)

This situation replicates an application using the ARMI framework. In that case, the application calls configure(App) at pytest_sessionstart but may not have any armi import statements in that conftest.py file resulting in the armi import not occurring until the pytest_sessionstart call.

With changes above:

Image

vs default ARMI setup:

Image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions