mingxiao
mingxiao

Reputation: 1812

pycharm pytestrunner PluginManager unexpected keyword argument

I have a very simple test script just to learn pytest, tmp.py:

def square(x):
    return x*x
def test_square():
    assert square(4) == 16

Using Pycharm to run this script, I've configured my project setting such that pytest is used as my default test runner. When I run the above code I get the following error:

/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

I am running PyCharm 3.0 Professional edition, pytest 2.4.2, and python 2.7.5. It seems that its PyCharm itself that is causing the problem.

Upvotes: 9

Views: 2263

Answers (4)

Shai.U
Shai.U

Reputation: 1

In the PyCharm add pytest to your project by: Settings --> Project interpreter --> Click on the plus green icon --> search for "pytests" --> Click on the "Install package" button

Rerun, now it should work

Upvotes: 0

thule
thule

Reputation: 4232

PyCharm pytest helper does not seem to be compatible with newer pytest. Until they fix it, replacing it with the contents of your py.test script works just fine.

Helper is located at PyCharm.app/helpers/pycharm/pytestrunner.py (you can see this path when trying to run tests). Just put the output of cat `which py.test` in it, for me it is:

  __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')()
      )

Upvotes: 2

l0ki
l0ki

Reputation: 111

It seems issue was created in pycharm tracker http://youtrack.jetbrains.com/issue/PY-11235

Upvotes: 1

StrongFish
StrongFish

Reputation: 503

It appears to be an incompatibility between PyCharm and py.test 2.4.x. If you install py.test 2.3.5 (for example, pip install pytest==2.3.5) it works fine. I suggest submitting a bug report to JetBrains.

Upvotes: 11

Related Questions