Is there a way to run a .py at the very beginning besides __init__.py
?
My problem is I need to save the current database state before the parsing of the files changes things. Because I have temporary tests variables that change, but if I can store the state before parsing this would be fixed since I can just restore it at the end of the session.
I need to run a .py not just before the actual test session starts but before the other files are parsed.
example:
console> py.test tests/test_example.py
- need it to run here
collecting 0 items
tests/test_example.py
==== test session starts ====
conftest.py
runs here
You could say that an __init__.py
would be a solution but when there is an __init__.py
in the testing directory, pytest runs everything as a module. (instead of running from py._path.pyimport
, it runs from __init__.py
) This breaks all my tests and imports throughout my whole tests/ directory
So maybe I can crate my own py._path.pyimport
, this just doesn't seem to be the safest/correct way. Or is it possible to call an __init__.py
and still run from py._path.pyimport
after?