问题描述
我尝试使用nosetests
❯鼻子测试'/pathTo/test'
I try to use nosetests
❯ nosetests '/pathTo/test'
但它使用python 2.7
进行测试:
sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)
所以其中一些失败,因为它们是用python 3.3
编写的.
So some of them fails, because they were written in python 3.3
.
我可以解决并安装虚拟环境:
I work it around and installed virtual environment:
pyvenv-3.3 py3env
已激活它:
source ~/py3env/bin/activate
在虚拟环境中检查python病毒:
Check python virsion in virtual environment:
❯ python --version ⏎
Python 3.3.3
(py3env)
好的.但是,即使在虚拟环境中,鼻子测试仍然使用python2.7
:
Ok.But nosetest still uses python2.7
even in virtual environment:
sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)
所以我的测试失败了.如何使用python3制作鼻子?
So my tests fails.How to make nose use python3?
推荐答案
在Python 3.4
及更高版本中:为了使鼻子使用python3
,只需运行...
In Python 3.4
and higher versions: in order to make nose use python3
just run ...
python3 -m "nose"
...在具有测试的目标目录中.
... in the target directory with the tests.
不需要环境设置.
这篇关于如何使用python3进行鼻子测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!