问题
Similar to Force Nosetests to Use Python 2.7 instead of 3.4, I've written some unit tests in Python 2 which I'd like to run in Python 2. However, by default my installation of nose2
seems to try to run Python 3.
For example, if I try to run unittest_controller.py
I get output ending with
Ran 4 tests in 1.552s
OK
whereas if I use the command nose2
from the same directory, I get
ImportError: No module named 'StringIO'
----------------------------------------------------------------------
Ran 2 tests in 0.001s
FAILED (errors=2)
because StringIO
is no longer a module in Python 3. How can I run the tests using Python 2?
来源:https://stackoverflow.com/questions/40406122/force-nose2-to-use-python-2-7-instead-of-python-3-5