serhii.net

In the middle of the desert you can say anything you want

14 Jan 2022

pytest use conftest.py to run python code before the tests

A conftest.py file gets imported and run before all the other ones.

Pytest resolves all imports at the very beginning, I used conftest.py it to import a package so that it’ll be the one used by the imports in files that are imported in the tests (seeing that there’s a mypackage already imported, subsequent import mypackages are ignored)

(Can I think of this as something similar to an __init__.py?)

Nel mezzo del deserto posso dire tutto quello che voglio.