py.test -n <number of =“”processes =“”> =&gt; &#34; py.test:错误:无法识别的参数:-n&#34; </number>

时间:2014-06-13 06:07:30

标签: python django pytest

我正在尝试将django测试分发到多个进程以加快测试运行。

我在虚拟环境中使用py.test。

我的相关版本是:

$ pip freeze | grep test
django-pytest==0.2.0
django-webtest==1.7.7
pytest==2.5.2
pytest-cov==1.6
pytest-django==2.6.2
pytest-xdist==1.10
scripttest==1.3

当我尝试命令时:

$ py.test -n 4

我收到错误:

usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: -n

py.test traceconfig命令显示:

$ py.test --traceconfig
PLUGIN registered: <_pytest.python.FixtureManager instance at 0x1091fd320>
===================================================== test session starts ======================================================
platform darwin -- Python 2.7.2 -- py-1.4.20 -- pytest-2.5.2 --     /Users/mike/virtualenvs/foodnet/bin/python
using: pytest-2.5.2 pylib-1.4.20
setuptools registered plugins:
pytest-cov-1.6 at /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/pytest_cov.pyc
pytest-django-2.6.2 at /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/pytest_django/plugin.pyc

active plugins:

cacheprovider       : -1
helpconfig          : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/helpconfig.pyc
pytestconfig        : <_pytest.config.Config object at 0x108da9d50>
runner              : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/runner.pyc
unittest            : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/unittest.pyc
xdist               : -1
assertion           : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/assertion/__init__.pyc
pastebin            : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/pastebin.pyc
skipping            : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/skipping.pyc
genscript           : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/genscript.pyc
session             : <Session 'src'>
tmpdir              : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/tmpdir.pyc
capture             : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/capture.pyc
terminalreporter    : <_pytest.terminal.TerminalReporter instance at 0x1091ebcf8>
cache               : -1
4442026896          : <_pytest.config.PytestPluginManager object at 0x108c3f390>
mark                : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/mark.pyc
terminal            : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/terminal.pyc
main                : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/main.pyc
nose                : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/nose.pyc
python              : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/python.pyc
recwarn             : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/recwarn.pyc
funcmanage          : <_pytest.python.FixtureManager instance at 0x1091fd320>
monkeypatch         : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/monkeypatch.pyc
resultlog           : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/resultlog.pyc
cov                 : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/pytest_cov.pyc
capturemanager      : <_pytest.capture.CaptureManager instance at 0x1091ed710>
django              : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/pytest_django/plugin.pyc
pep8                : -1
junitxml            : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/junitxml.pyc
doctest             : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/doctest.pyc
pdb                 : /Users/mike/virtualenvs/foodnet/lib/python2.7/site-packages/_pytest/pdb.pyc

插件:cov,django

我注意到xdist插件旁边有一个-1。这是否表示该插件出错?

py.test --help没有列出xdist参数

1 个答案:

答案 0 :(得分:1)

想出来的是:

-p no:xdist 

在tox.ini的addopts部分中。删除它,xdist工作。