Open shenganzhang opened 2 years ago
May I ask why you need to test it with pytest-randomly?
This is to improve the robustness of the testsuite.
Thanks for reporting this. I think this is an issue we need to resolve. Mind take a stab on it?
@laike9m Can I work on this issue?
@kshivakumar Sure. If you have any questions, let me know
Any of the below commands will cause a test case to fail
pytest tests/test_user_config.py::test_invalid_config_1
pytest tests/test_user_config.py::test_read_config
pytest --randomly-seed=1234 tests/test_user_config.py
(One test case fails randomly)Test cases in test_user_config.py fail if the order of execution changes. Specifically, if a test case other than test_default_env_without_config
or test_empty_config
is executed first, then that test case fails and remaining all pass.
In our clean
fixture, we are unloading pdir
related modules in the teardown step. That means, whichever test case executes first, pdir
related import statements are not executed inside that test case because the modules are already available. Since the imports are not executed, the config based on new file path is also not loaded.
After the first test case is executed, irrespective of whether it fails or passes, the teardown step in the fixture is executed which unloads the pdir
modules giving a clean slate for the second test case.
test_default_env_without_config
or test_empty_config
use default config values. So, there’s no affect of config file on them, they always pass.
https://github.com/laike9m/pdir2/pull/59 fixes this.
tests/test_user_config.py::test_invalid_config_1
can run into failure when executing the following commands:pip install pytest-randomly
pytest --randomly-seed=1234