I have a simple python module (let's call it M1) which is standalone (the only import is to collections
), inside a package containing ugliness. Part of the ugliness is in the package's __init__.py
file. But M1 is nice and clean, and contains some test functions for use with py.test.
Now, I would like to test M1 and ignore all the ugliness. But py.test wants to run __init__.py
-- is there any way I can prevent this? I really can't fix the __init__.py
file at this time, and I want to keep my test functions contained right alongside the M1 module contents itself.
I've already read this SO question: `py.test` and `__init__.py` files which explains the issue but offers no solution.
my __init__.py
file looks something like this; it's just promoting items into package scope:
from .M1 import CleanThing1, CleanThing2
from .Evil1 import UglyThing1, UglyThing2
and the problem is that the Evil1 module requires some PYTHONPATH hackery to execute properly, and when I run
py.test mymodule/M1.py
it fails because of the Evil1 module. But I just want to test the M1 module right now.