[英]Why do I get the error “Invalid command nosetests” when I run nosetests from my virtualenv?
I first noticed the problem with this project when I loaded it into Jenkins. 当我把它加载到Jenkins时,我首先注意到这个项目的问题。 More puzzlingly, I've been able to reproduce it as follows:
更令人费解的是,我已经能够重现如下:
In original version of the project, the following command runs tests as expected: 在项目的原始版本中,以下命令按预期运行测试:
.venv/bin/python setup.py nosetests
I then do the following: 然后我做以下事情:
.venv
in clone .venv
If I then run .venv/bin/python setup.py nosetests
on this version and I get the following result: 如果我然后在这个版本上运行
.venv/bin/python setup.py nosetests
,我得到以下结果:
setup.py: error: Invalid command nosetests
setup.py
includes the following settings: setup.py
包括以下设置:
setup_requires=[
'nose>=1.0', 'nosexcover', 'coverage', 'selenium', 'fixture'
],
test_suite='nose.collector',
I'm especially baffled because it's the same setup.py
and setup.cfg
files in each version and, as far as I been able to discern, the environments are identical. 我特别困惑,因为它在每个版本中都是相同的
setup.py
和setup.cfg
文件,并且据我所知,环境是相同的。
I noticed this Stack Overflow question in the sidebar, which looks closely related, but none of the solutions offered there are working in my case. 我在边栏中注意到这个Stack Overflow问题 ,它看起来非常相关,但是我提供的解决方案都没有。
I ran into the same problem and managed to fix it by putting 我遇到了同样的问题并设法通过推杆修复它
setup_requires=['nose>=1.0']
Into my setup.py
file. 进入我的
setup.py
文件。 After that the Python setup.py nosetests
option was available to me. 之后,我可以使用Python
setup.py nosetests
选项。
Some links that were helpful: 一些有用的链接:
I never figured out the underlying issue exactly. 我从来没有完全弄清楚潜在的问题。 But I did figure out a workaround that allowed me to get my build running.
但我确实找到了一个允许我让我的构建运行的解决方法。 This is the command I used in the Virtualenv Builder on Jenkins:
这是我在Jenkins的Virtualenv Builder中使用的命令:
# require nosetests be installed
# (old method using setup.py nosetests command does not work)
$VIRTUAL_ENV/bin/pip install nose
# install remain pip requirements
$VIRTUAL_ENV/bin/pip install -r requirements.pip
# must run this prior to running tests to install other nosetest dependencies
$VIRTUAL_ENV/bin/python setup.py install
# now we can run nosetests
# this does not work: $VIRTUAL_ENV/bin/python setup.py nosetests
$VIRTUAL_ENV/bin/nosetests -c setup.cfg
I suspect the root problem has to do with the state of the virtual environment and some kind of version incompatibility between Distutils and Nose in my new virtualenv. 我怀疑根本问题与我的新virtualenv中虚拟环境的状态和Distutils和Nose之间的某种版本不兼容有关。 The old one seems to have arrived at a certain precarious configuration over time which cloning and pip alone cannot recreate.
旧的似乎随着时间的推移已经达到了某种不稳定的配置,克隆和pip无法再创造。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.