Skip to content
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

tests/test_user_config.py failure #58

Open
shenganzhang opened this issue Nov 11, 2021 · 6 comments
Open

tests/test_user_config.py failure #58

shenganzhang opened this issue Nov 11, 2021 · 6 comments

Comments

@shenganzhang
Copy link

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

@laike9m
Copy link
Owner

laike9m commented Nov 12, 2021

May I ask why you need to test it with pytest-randomly?

@shenganzhang
Copy link
Author

This is to improve the robustness of the testsuite.

@laike9m
Copy link
Owner

laike9m commented Nov 29, 2021

Thanks for reporting this. I think this is an issue we need to resolve. Mind take a stab on it?

@kshivakumar
Copy link
Contributor

@laike9m Can I work on this issue?

@laike9m
Copy link
Owner

laike9m commented Jan 28, 2022

@kshivakumar Sure. If you have any questions, let me know

@kshivakumar
Copy link
Contributor

kshivakumar commented Feb 1, 2022

Steps to reproduce Error

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)

Observations

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.

Root Cause Analysis

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.

#59 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants