-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One test failing in test_utils.py when running pytest tests #1521
Comments
EDIT: Ignore the above I misread your comment, hadn't realised this was appearing after running in conjuction with |
So I think this is happening because of the TLOmodel/tests/test_logging.py Lines 69 to 83 in 49acef5
This was intended to allow testing functions which alter the global logging state without coupling them together by resetting the global state to what is was at the (first) import of What I didn't account for in this is that the global logging state is affected by the various TLOmodel/tests/test_logging.py Line 83 in 49acef5
so that the global state is not reset appears to resolve the test failure issue. Ideally it would be good to still allow explicitly resetting the global logging state to a previous value in tests, but I think a context manager solution for doing this might work better - that is the context manager records initial global state, yields to code in a |
Thanks Matt |
When running
pytest tests
in the local environment,test_utils
fails with the following error:FAILED tests/test_utils.py::test_logs_parsing - AssertionError: assert 'tlo.methods.demography' in {}
Interestingly, running
pytest tests/test_utils.py
alone works perfectly fine, and all tests pass. After a quick debug, it appears that the issue is caused by another test,test_logging.py
. Specifically, when runningpytest tests/test_logging.py tests/test_utils.py
, thetest_utils
fails with the above error. I guesstest_logging
is modifying some global state, as running the tests in a different order (pytest tests/test_utils.py tests/test_logging.py
) resolves the issue, and all tests pass successfully.@tamuri or @matt-graham can you help looking into this?
The text was updated successfully, but these errors were encountered: