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 thetestspath, so test files can import common. - Not import
packagebefore running tests, because I need to test that the configs load correctly (and so need to make changes to environment variables before importingpackageand test that flows through to its configs). Nosetests seems to insist on importingpackageiftestsis 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