在eclipse中配置Python项目

时间:2016-07-20 07:40:50

标签: python eclipse pycharm pydev

实际上我正在尝试在Eclipse中使用python框架(使用PyDev插件) - 该框架是在PyCharm IDE中设计的,我们在其中进行一些配置,如下面的屏幕截图所示:

enter image description here

我尝试过搜索参考链接,但到目前为止还没有运气。那么有人可以帮助我如何在Eclipse中配置目标,关键字,选项参数吗?

********添加一些额外信息********

在此,我按照指示添加了一些基本片段 -

import pytest

@pytest.mark.test
def test_method():
    print "test method"

class TestClass:
    def test_one(self):
        x = "this"
        assert 'h' in x

    def test_two(self):
        x = "hello"
        assert 'o' in x

当我尝试使用以下命令通过命令提示符运行它时,它正常工作

  

$ py.test -k“test”

     

=============================测试会话开始=============== ==============平台win32 - Python 2.7.12 - pytest-2.5.1插件:xdist,xdist,xdist收集了3个项目

     

test_sample.py ...

     

========================== 3在0.05秒内通过================ ===========

但是当我尝试通过Eclipse PyDev运行它时,它不起作用,请通知我已经将PyUnit测试运行器选项更改为blog中指定的Py.test运行程序。我还尝试在运行>中提供-k "test"选项运行配置>参数,但是如下所示得到一些突然的例外 - 请帮忙!

  

Traceback(最近一次调用最后一次):文件   “d:\日食\插件\ org.python.pydev_5.1.2.201606231256 \ pysrc \ runfiles.py”   第241行       main()文件“D:\ eclipse \ plugins \ org.python.pydev_5.1.2.201606231256 \ pysrc \ runfiles.py”,   第233行,主要       return pytest.main(argv)文件“C:\ Python27 \ lib \ site-packages_pytest \ config.py”,第18行,主要       config = _prepareconfig(args,plugins)文件“C:\ Python27 \ lib \ site-packages_pytest \ config.py”,第62行,in   _prepareconfig       pluginmanager = pluginmanager,args = args)文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第376行,调用       return self._docall(methods,kwargs)_docall中的文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第387行       res = mc.execute()文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第288行,执行中       res =方法(** kwargs)文件“C:\ Python27 \ lib \ site-packages_pytest \ helpconfig.py”,第25行,in   pytest_cmdline_parse       config = multicall .execute()文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第288行,执行中       res =方法(** kwargs)文件“C:\ Python27 \ lib \ site-packages_pytest \ config.py”,第617行,in   pytest_cmdline_parse       self.parse(args)文件“C:\ Python27 \ lib \ site-packages_pytest \ config.py”,第710行,解析       self._preparse(args)文件“C:\ Python27 \ lib \ site-packages_pytest \ config.py”,第686行,in   _preparse       self.pluginmanager.consider_preparse(args)文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第185行,in   consider_preparse       self.consider_pluginarg(opt2)文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第195行,in   consider_pluginarg       self.import_plugin(arg)文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第214行,   import_plugin       mod = importplugin(modname)文件“C:\ Python27 \ lib \ site-packages_pytest \ core.py”,第269行,in   importplugin       导入(importspec)文件“D:\ eclipse \ plugins \ org.python.pydev_5.1.2.201606231256 \ pysrc_pydev_runfiles \ pydev_runfiles_pytest2.py”,   284行       @ pytest.hookimpl(hookwrapper = True)AttributeError:'module'对象没有属性'hookimpl'

1 个答案:

答案 0 :(得分:1)

嗯,你能更新你的pytest版本并重试吗?你使用哪个pytest版本?

即。似乎PyDev现在要求pytest 2.7以上(hookwrapper:在其他钩子周围执行是版本2.7中的新功能:http://docs.pytest.org/en/latest/writing_plugins.html)。

作为一个注释,pytest 2.7是从2015年3月26日开始的,所以,它已经相对较老了。