我已经在工作的pytest环境中安装了pytest-xdist:
pip install pytest-xdist
我收到了这个输出
Downloading/unpacking pytest-xdist
Downloading pytest-xdist-1.10.tar.gz
Running setup.py egg_info for package pytest-xdist
no previously-included directories found matching '.hg'
Downloading/unpacking execnet>=1.1 (from pytest-xdist)
Downloading execnet-1.2.0.tar.gz (163kB): 163kB downloaded
Running setup.py egg_info for package execnet
warning: no files found matching 'conftest.py'
Requirement already satisfied (use --upgrade to upgrade): pytest>=2.4.2 in /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages (from pytest-xdist)
Requirement already satisfied (use --upgrade to upgrade): py>=1.4.20 in /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages (from pytest>=2.4.2->pytest-xdist)
Installing collected packages: pytest-xdist, execnet
Running setup.py install for pytest-xdist
no previously-included directories found matching '.hg'
Running setup.py install for execnet
warning: no files found matching 'conftest.py'
Successfully installed pytest-xdist execnet
Cleaning up...
此时我试图并行运行我的测试套件
py.test -n 4
但我收到了这个输出
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: -n
' py.test --version的输出是'
This is pytest version 2.6.2, imported from /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages/pytest.pyc
setuptools registered plugins:
pytest-capturelog-0.7 at /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages/pytest_capturelog.pyc
pytest-contextfixture-0.1.1 at /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages/pytest_contextfixture.pyc
pytest-cov-1.7.0 at /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages/pytest_cov.pyc
pytest-django-2.6.2 at /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages/pytest_django/plugin.pyc
pytest-pydev-0.1 at /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages/pytest_pydev.pyc
pytest-runfailed-0.3 at /Users/sal/Documents/code/Python/VirtualEnv/Spring/lib/python2.7/site-packages/pytest_runfailed.pyc
和pytest-xdist实际上是缺失的。
我错了什么?感谢。
答案 0 :(得分:1)
我遇到了同样的问题。问题不在于版本。某种程度上py.test无法看到xdist的位置。这对我有用:
pip install pytest --user
pip install pytest-xdist --user
export PATH = $ HOME / .local / bin:$ PATH
答案 1 :(得分:0)
请尝试py.test --version
并查看解释导入位置的输出,包括插件。很可能没有运行您认为正在运行的py.test
。
答案 2 :(得分:0)
我遇到了这个问题并且发现它是因为一个非常古老的setuptools
(Centos6.7上提供的默认版本)
pip list | grep setuptools
setuptools (0.6rc11)
首先升级setuptools
sudo pip install --upgrade setuptools
然后重新安装pytest
和pytest-xdist
sudo pip install --upgrade pytest pytest-xdist --force-reinstall
此后pytest
能够发现xdist
插件。