python – Pytest在安装pytest-xdist后无法识别-n选项
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python – Pytest在安装pytest-xdist后无法识别-n选项,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3882字,纯文字阅读大概需要6分钟。
内容图文
![python – Pytest在安装pytest-xdist后无法识别-n选项](/upload/InfoBanner/zyjiaocheng/804/3715e5d9a40a45d0941dad3955e53d27.jpg)
我已经在一个正常工作的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实际上是缺失的.
我错了什么?谢谢.
解决方法:
像user2412166一样,我遇到了同样的问题.与user2412166不同,我的解决方案是放宽pip3安装的xdist和pytest_xdist-1.14.dist-info系统目录的权限.
一些背景故事:为了安全起见,我在我的系统上运行严格的umask,禁止所有访问其他用户并默认写入组用户的权限:
$umask
027
虽然这通常是一件好事,但偶尔也会让我遇到麻烦.在这个umask下通过pip3安装python-xdist:
$sudo pip3 install pytest-xdist
…导致pip3禁止对非超级用户的读取和执行访问 – 最好只有我:
$ls -l /usr/lib64/python3.4/site-packages/xdist
drwxr-x--- 3 root root 4.0K 2016-04-10 01:19 xdist/
$ls -l /usr/lib64/python3.4/site-packages/pytest_xdist-1.14.dist-info
drwxr-x--- 3 root root 4.0K 2016-04-10 01:19 xdist/
虽然pip3这样做并没有错,但是py.test在安静地忽略而不是在插件检测期间明确报告明显的权限问题时(…可能!)是错误的.
通过递归授予其他用户对受影响的系统目录的读取和目录执行权限,可以轻松解决这个问题:
$chmod -R o+rX /usr/lib64/python3.4/site-packages/xdist
$chmod -R o+rX /usr/lib64/python3.4/site-packages/pytest_xdist-1.14.dist-info
证明是命令行布丁:
$ls -l /usr/lib64/python3.4/site-packages/xdist
drwxr-xr-x 3 root root 4.0K 2016-04-10 01:19 xdist/
$ls -l /usr/lib64/python3.4/site-packages/pytest_xdist-1.14.dist-info
drwxr-xr-x 3 root root 4.0K 2016-04-10 01:19 xdist/
$py.test --version
This is pytest version 2.8.7, imported from /usr/lib64/python3.4/site-packages/pytest.py
setuptools registered plugins:
pytest-xdist-1.14 at /usr/lib64/python3.4/site-packages/xdist/looponfail.py
pytest-xdist-1.14 at /usr/lib64/python3.4/site-packages/xdist/plugin.py
pytest-xdist-1.14 at /usr/lib64/python3.4/site-packages/xdist/boxed.py
因此,目前尚不明确,调试错误,慢速测试快速并行化.
内容总结
以上是互联网集市为您收集整理的python – Pytest在安装pytest-xdist后无法识别-n选项全部内容,希望文章能够帮你解决python – Pytest在安装pytest-xdist后无法识别-n选项所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。