zeal
zeal

Reputation: 475

Configuring Python project in eclipse

Actually I'm trying to use a python framework in Eclipse (with PyDev plugin) - the framework was designed in PyCharm IDE where we do some configuration as in the screenshot below:

enter image description here

I've tried searching for reference links, but no luck so far. So can someone help me on how to configure Target, Keywords, Options parameter in Eclipse?

******** ADDING SOME ADDITIONAL INFO ********

Herewith, I'm adding some basic snippet as instructed -

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

It's working fine when I try to run it through command prompt using the following command

$ py.test -k "test"

============================= test session starts ============================= platform win32 -- Python 2.7.12 -- pytest-2.5.1 plugins: xdist, xdist, xdist collected 3 items

test_sample.py ...

========================== 3 passed in 0.05 seconds ===========================

But it's not working when I try to run it through Eclipse PyDev, please be informed I've changed the PyUnit test runner option to Py.test runner as specified in blog. I have also tried to provide the -k "test" option in Run > Run Configurations > Arguments, but getting some abrupt exception as below - please help!

Traceback (most recent call last): File "D:\eclipse\plugins\org.python.pydev_5.1.2.201606231256\pysrc\runfiles.py", line 241, in main() File "D:\eclipse\plugins\org.python.pydev_5.1.2.201606231256\pysrc\runfiles.py", line 233, in main return pytest.main(argv) File "C:\Python27\lib\site-packages_pytest\config.py", line 18, in main config = _prepareconfig(args, plugins) File "C:\Python27\lib\site-packages_pytest\config.py", line 62, in _prepareconfig pluginmanager=pluginmanager, args=args) File "C:\Python27\lib\site-packages_pytest\core.py", line 376, in call return self._docall(methods, kwargs) File "C:\Python27\lib\site-packages_pytest\core.py", line 387, in _docall res = mc.execute() File "C:\Python27\lib\site-packages_pytest\core.py", line 288, in execute res = method(**kwargs) File "C:\Python27\lib\site-packages_pytest\helpconfig.py", line 25, in pytest_cmdline_parse config = multicall.execute() File "C:\Python27\lib\site-packages_pytest\core.py", line 288, in execute res = method(**kwargs) File "C:\Python27\lib\site-packages_pytest\config.py", line 617, in pytest_cmdline_parse self.parse(args) File "C:\Python27\lib\site-packages_pytest\config.py", line 710, in parse self._preparse(args) File "C:\Python27\lib\site-packages_pytest\config.py", line 686, in _preparse self.pluginmanager.consider_preparse(args) File "C:\Python27\lib\site-packages_pytest\core.py", line 185, in consider_preparse self.consider_pluginarg(opt2) File "C:\Python27\lib\site-packages_pytest\core.py", line 195, in consider_pluginarg self.import_plugin(arg) File "C:\Python27\lib\site-packages_pytest\core.py", line 214, in import_plugin mod = importplugin(modname) File "C:\Python27\lib\site-packages_pytest\core.py", line 269, in importplugin import(importspec) File "D:\eclipse\plugins\org.python.pydev_5.1.2.201606231256\pysrc_pydev_runfiles\pydev_runfiles_pytest2.py", line 284, in @pytest.hookimpl(hookwrapper=True) AttributeError: 'module' object has no attribute 'hookimpl'

Upvotes: 0

Views: 846

Answers (1)

Fabio Zadrozny
Fabio Zadrozny

Reputation: 25332

Humm, can you update your pytest version and retry that? Which pytest version are you using?

I.e. it seems PyDev is now requiring pytest 2.7 onwards (hookwrapper: executing around other hooks is New in version 2.7 from: http://docs.pytest.org/en/latest/writing_plugins.html).

As a note, pytest 2.7 is from Mar 26, 2015, so, it's already relatively old.

Upvotes: 1

Related Questions