When and how often is conftest.py loaded? #11312
-
Hello, I wonder if this import would happen once for all tests, once per test module, one per individual test? In other words, would the mock_object used be the same for all tests, all tests in a module or be separate for each test? This affects possible cleanups to be done. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
first, a conftest should never throw in mocks at import time, it completely breaks details even if it looks like its working second - conftests are either loaded at pytest startup (early conftests) or at collection time (the rest of them) all conftests are supposed to be imported once |
Beta Was this translation helpful? Give feedback.
first, a conftest should never throw in mocks at import time, it completely breaks details even if it looks like its working
second - conftests are either loaded at pytest startup (early conftests) or at collection time (the rest of them)
all conftests are supposed to be imported once