0

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'

7
  • It seems PyDev puts all the options in one place; see pydev.org/manual_adv_pyunit.html, which also links to the py.test docs. Commented Jul 20, 2016 at 7:46
  • No it didn't workout... i've tried updating like -k=sanity --project=city1 --env=city1_sit --translation=ct... but got some error like AttributeError: 'module' object has no attribute 'hookimpl' Commented Jul 20, 2016 at 9:44
  • Then please edit the question with a minimal reproducible example. Commented Jul 20, 2016 at 9:44
  • @jonrsharpe - I understand your ask, but to be honest I'm not that much expert to shrink the framework to minimal snippet and share for reference. But my question is similar to link, there he asked for PyCharm. It may also give similar details, but at least in different way! Commented Jul 21, 2016 at 7:12
  • You could at the very least provide a traceback to tell us where that error gets thrown. If it's just from py.test, before reaching your tests, none of the code you've actually written is relevant. But I can't tell that from here, you need to try setting up a clean project and moving in minimal code until it replicates the error. Indeed you should have already done this, that's basic debugging. Commented Jul 21, 2016 at 7:29

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep, perfect it worked. Previously I had pytest 2.5.1 and now upgraded to latest one. Could you please confirm where could I specify the command line option value in PyDev? I'm trying something like pytest.config.getoption("test"), any suggestion? While tying this I also noted that PyDev throws error stating that Undefined variable from import: config.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.