Force nose2 to use Python 2.7 instead of Python 3.5

青春壹個敷衍的年華 提交于 2020-01-15 08:51:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!