我有一个非常简单的测试脚本来学习pytest,tmp.py:
def square(x):
return x*x
def test_square():
assert square(4) == 16使用Pycharm运行这个脚本,我配置了我的项目设置,使pytest被用作我的默认测试运行程序。当我运行上面的代码时,我会得到以下错误:
/Users/mingxiao/webdav_2.7.5/bin/python /Applications/PyCharm.app/helpers/pycharm/pytestrunner.py -p pytest_teamcity /Users/mingxiao/dev/juggernaut/src/integrations/webDAV/demo/tmp.py "-k test_square"
Testing started at 4:41 PM ...
Traceback (most recent call last):
File "/Applications/PyCharm.app/helpers/pycharm/pytestrunner.py", line 51, in <module>
main()
File "/Applications/PyCharm.app/helpers/pycharm/pytestrunner.py", line 20, in main
_pluginmanager = PluginManager(load=True)
TypeError: __init__() got an unexpected keyword argument 'load'
Process finished with exit code 1我正在运行PyCharm 3.0专业版,pytest 2.4.2和python2.7.5。似乎是它的PyCharm本身造成了这个问题。
发布于 2013-10-08 12:38:46
这似乎是PyCharm和py.test 2.4.x之间的不兼容。如果安装py.test 2.3.5 (例如,pip install pytest==2.3.5),它可以正常工作。我建议向JetBrains提交一个bug报告。
发布于 2014-01-23 11:51:32
PyCharm pytest助手似乎与新的pytest不兼容。在他们修复之前,用您的py.test脚本的内容来替换它是很好的。
Helper位于PyCharm.app/helpers/pycharm/pytestrunner.py (在尝试运行测试时可以看到此路径)。只要把cat `which py.test`的输出放进去,对我来说就是:
__requires__ = 'pytest==2.5.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pytest==2.5.1', 'console_scripts', 'py.test')()
)发布于 2014-01-12 11:24:20
问题似乎是在火药追踪器http://youtrack.jetbrains.com/issue/PY-11235中产生的。
https://stackoverflow.com/questions/19236745
复制相似问题