How can I force nosetests
to run each unit test in a new Python instance?
I'm having a weird situation here, I have a simple plugin system based on enumerating __subclasses__()
of a Plugin
base class out of which plugins are derived. My problem arises from the fact that nosetests
seems to reuse (?) the python instance to run all unit tests and, because of that, one of the unit tests ends up "seeing" a plugin defined in another.
For a proof of concept, I have the following directory structure:
.
|-- package
| |-- __init__.py
| `-- plugin.py
|-- unit_test_1.py
`-- unit_test_2.py
The contents of the files can be found here. Now, if I run unit_test_1.py
or unit_test_2.py
individually, they both succeed. However, if I use nosetests
to run both of them, the second unit test will failed due to the length of __subclasses__()
being two.