-
Notifications
You must be signed in to change notification settings - Fork 94
Description
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:
- 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 invokingconftest.py
) - Move the import statements in
conftest.py
from the top of the file to be local to the function they are used in. - 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:

vs default ARMI setup:
