I have the following directory structure
package
__init__.py
module1
model1.py
tests
__init__.py
common.py
test_module1
test_model1.py
I need to:
- Have a place to put common 'helpers' for tests, such as shared data. I'm currently using
common.py
. I think this necessitates having an__init__
in thetests
path, so test files can import common. - Not import
package
before running tests, because I need to test that the configs load correctly (and so need to make changes to environment variables before importingpackage
and test that flows through to its configs). Nosetests seems to insist on importingpackage
iftests
is a package (i.e. if there's an__init__
in tests).
Is there a way of doing this? Or should I be changing my setup? I could have common
in package
directly, although that seems awkward.
A question that touches on this issue: Python imports for tests using nose - what is best practice for imports of modules above current package