Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError - ERROR: InvocationError for command '**\.tox\py35\Scripts\python' '**\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py' -p pytest_teamcity tests (exited with code 1) #5800

Closed
5 tasks done
sanghvibk opened this issue Aug 29, 2019 · 15 comments
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@sanghvibk
Copy link

sanghvibk commented Aug 29, 2019

  • a detailed description of the bug or suggestion
    While running tox command from PyCharm (version 2019.2) and PyTest (version 5.1.1), I am getting an error "AssertionError - ERROR: InvocationError for command '.tox\py35\Scripts\python' '\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py' -p pytest_teamcity tests (exited with code 1)". I was able to resolve this issue by forcing tox to use PyTest version 5.0.1 OR 4.6.2. I managed to find source of exception in file **.tox\py35\lib\site-packages_pytest\config_init_.py - line 920 - "assert self.invocation_params.args == args"

  • output of pip list from the virtual environment you are using

Package Version
atomicwrites 1.3.0
attrs 19.1.0
colorama 0.4.1
filelock 3.0.12
importlib-metadata 0.19
more-itertools 7.2.0
packaging 19.1
pathlib2 2.3.4
pip 19.2.3
pluggy 0.12.0
py 1.8.0
pyparsing 2.4.2
pytest 5.1.1
setuptools 41.2.0
six 1.12.0
toml 0.10.0
tox 3.13.2
virtualenv 16.7.4
wcwidth 0.1.7
zipp 0.6.0
  • pytest and operating system versions
    pytest - 5.1.1 / OS version : latest version of Windows 10 Home as well as latest version of Raspbian

  • example of tox.ini having issue with ...
    tox.ini file is like ...

[tox]
envlist = py{35}

[testenv]
basepython =
    py35: python3.5
deps =
    check-manifest
    # If your project uses README.rst, uncomment the following:
    # readme_renderer
    flake8
    pytest
commands =
    check-manifest --ignore tox.ini,tests*
    # This repository uses a Markdown long_description, so the -r flag to
    # `setup.py check` is not needed. If your project contains a README.rst,
    # use `python setup.py check -m -r -s` instead.
    python setup.py check -m -s
    flake8 .
    py.test tests
[flake8]
    exclude = .tox,*.egg,build,data
    select = E,W,F
  • example of tox.ini NOT having this issue ...
    tox.ini file is like ...
[tox]
envlist = py{35}

[testenv]
basepython =
    py35: python3.5
deps =
    check-manifest
    # If your project uses README.rst, uncomment the following:
    # readme_renderer
    flake8
    pytest==5.0.1
commands =
    check-manifest --ignore tox.ini,tests*
    # This repository uses a Markdown long_description, so the -r flag to
    # `setup.py check` is not needed. If your project contains a README.rst,
    # use `python setup.py check -m -r -s` instead.
    python setup.py check -m -s
    flake8 .
    py.test tests
[flake8]
    exclude = .tox,*.egg,build,data
    select = E,W,F
@sanghvibk
Copy link
Author

I believe, this issue is caused by #5564 and/or #5644

@nicoddemus
Copy link
Member

Hi @sanghvibk,

Can you manage to post the complete traceback? That assert shouldn't really be failing... 🤔

@nicoddemus nicoddemus added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Aug 29, 2019
@sanghvibk
Copy link
Author

Hi @nicoddemus , Many thanks for your response. Please find full traceback as requested. Also, please let me know if I could provide any other assistance.

py35 run-test: commands[3] | 'D:\Work\Study\sampleproject\.tox\py35\Scripts\python' 'C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py' -p pytest_teamcity tests
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py", line 60, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py", line 34, in main
    pluginmanager=_pluginmanager, args=args)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\callers.py", line 203, in _multicall
    gen.send(outcome)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\_pytest\config\__init__.py", line 716, in pytest_cmdline_parse
    self.parse(args)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\_pytest\config\__init__.py", line 920, in parse
    assert self.invocation_params.args == args
AssertionError
ERROR: InvocationError for command 'D:\Work\Study\sampleproject\.tox\py35\Scripts\python' 'C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py' -p pytest_teamcity tests (exited with code 1)

commands failed
___________________________________ summary ___________________________________
ERROR:   py35: commands failed

@blueyed
Copy link
Contributor

blueyed commented Aug 30, 2019

Can you change it to output the values?

assert self.invocation_params.args == args, (assert self.invocation_params.args, args)

@sanghvibk
Copy link
Author

args = <class 'list'>: ['-p', 'pytest_teamcity', 'tests', '-s']
self.invocation_params.args = None

If you are expecting full Traceback with variable values, then please guide me how to achieve that. I am quite newbie with PyCharm / Python / PyTest.

@sanghvibk
Copy link
Author

After changing line 920 in init.py to assert self.invocation_params.args == args, (self.invocation_params.args, args)

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py", line 60, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py", line 34, in main
    pluginmanager=_pluginmanager, args=args)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\callers.py", line 203, in _multicall
    gen.send(outcome)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\_pytest\config\__init__.py", line 716, in pytest_cmdline_parse
    self.parse(args)
  File "D:\Work\Study\sampleproject\.tox\py35\lib\site-packages\_pytest\config\__init__.py", line 920, in parse
    assert self.invocation_params.args == args, (self.invocation_params.args, args)
AssertionError: (None, ['-p', 'pytest_teamcity', 'tests', '-s'])
ERROR: InvocationError for command 'D:\Work\Study\sampleproject\.tox\py35\Scripts\python' 'C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\pytestrunner.py' -p pytest_teamcity tests (exited with code 1)

commands failed

@sanghvibk
Copy link
Author

Hi @blueyed and @nicoddemus, Thank you for support so far. Kindly let me know if you would like to have any more information in order to establish cause of this issue. Regards.

@RonnyPfannschmidt
Copy link
Member

at first glance this looks like the pycharm helper is using pytest internals, can you upload that main file of pycharm ?

@sanghvibk
Copy link
Author

at first glance this looks like the pycharm helper is using pytest internals, can you upload that main file of pycharm ?

Thanks.

Please find attached pytestrunner.zip

@nicoddemus
Copy link
Member

nicoddemus commented Sep 5, 2019

Hi @sanghvibk,

I've installed 2019.2 (I was using 2018.3), and I now get several strange errors when running the test suite:

C:\Users\bruno\pytest\.env36\Scripts\python.exe W:\PyCharm\helpers\pycharm\_jb_pytest_runner.py --target test_collection.py::test_exit_on_collection_with_maxfail_bigger_than_n_errors
Launching pytest with arguments test_collection.py::test_exit_on_collection_with_maxfail_bigger_than_n_errors in C:\Users\bruno\pytest\testing

============================= test session starts =============================
platform win32 -- Python 3.6.8, pytest-5.1.2.dev17+g53291287c, py-1.8.0, pluggy-0.12.0 -- C:\Users\bruno\pytest\.env36\Scripts\python.exe
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('C:\\Users\\bruno\\pytest\\testing\\.hypothesis\\examples')
rootdir: C:\Users\bruno\pytest, inifile: tox.ini
plugins: hypothesis-4.24.1
collecting ... collected 1 item

test_collection.py::test_exit_on_collection_with_maxfail_bigger_than_n_errors Traceback (most recent call last):
  File "C:\Users\bruno\pytest\src\_pytest\pytester.py", line 864, in runpytest_inprocess
    reprec = self.inline_run(*args, **kwargs)
  File "C:\Users\bruno\pytest\src\_pytest\pytester.py", line 830, in inline_run
    ret = pytest.main(list(args), plugins=plugins)
  File "C:\Users\bruno\pytest\src\_pytest\config\__init__.py", line 78, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "C:\Users\bruno\pytest\.env36\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "C:\Users\bruno\pytest\.env36\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\Users\bruno\pytest\.env36\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "C:\Users\bruno\pytest\.env36\lib\site-packages\pluggy\callers.py", line 208, in _multicall
    return outcome.get_result()
  File "C:\Users\bruno\pytest\.env36\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "C:\Users\bruno\pytest\.env36\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "C:\Users\bruno\pytest\src\_pytest\main.py", line 228, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "C:\Users\bruno\pytest\src\_pytest\main.py", line 182, in wrap_session
    session = Session(config)
  File "C:\Users\bruno\pytest\src\_pytest\main.py", line 385, in __init__
    self.config.pluginmanager.register(self, name="session")
  File "C:\Users\bruno\pytest\src\_pytest\config\__init__.py", line 324, in register
    ret = super().register(plugin, name)
  File "C:\Users\bruno\pytest\.env36\lib\site-packages\pluggy\manager.py", line 100, in register
    % (plugin_name, plugin, self._name2plugin)
ValueError: Plugin already registered: session=<Session pytest exitstatus='<UNSET>' testsfailed=0 testscollected=0>
{'1148867193320': <_pytest.config.PytestPluginManager object at 0x0000010B7DD229E8>, 'pytestconfig': <_pytest.config.Config object at 0x0000010B7DE16A58>, 'mark': <module '_pytest.mark' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\mark\\__init__.py'>, 'main': <module '_pytest.main' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\main.py'>, 'runner': <module '_pytest.runner' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\runner.py'>, 'fixtures': <module '_pytest.fixtures' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\fixtures.py'>, 'helpconfig': <module '_pytest.helpconfig' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\helpconfig.py'>, 'python': <module '_pytest.python' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\python.py'>, 'terminal': <module '_pytest.terminal' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\terminal.py'>, 'debugging': <module '_pytest.debugging' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\debugging.py'>, 'unittest': <module '_pytest.unittest' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\unittest.py'>, 'capture': <module '_pytest.capture' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\capture.py'>, 'skipping': <module '_pytest.skipping' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\skipping.py'>, 'tmpdir': <module '_pytest.tmpdir' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\tmpdir.py'>, 'monkeypatch': <module '_pytest.monkeypatch' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\monkeypatch.py'>, 'recwarn': <module '_pytest.recwarn' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\recwarn.py'>, 'pastebin': <module '_pytest.pastebin' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\pastebin.py'>, 'nose': <module '_pytest.nose' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\nose.py'>, 'assertion': <module '_pytest.assertion' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\assertion\\__init__.py'>, 'junitxml': <module '_pytest.junitxml' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\junitxml.py'>, 'resultlog': <module '_pytest.resultlog' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\resultlog.py'>, 'doctest': <module '_pytest.doctest' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\doctest.py'>, 'cacheprovider': <module '_pytest.cacheprovider' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\cacheprovider.py'>, 'freeze_support': <module '_pytest.freeze_support' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\freeze_support.py'>, 'setuponly': <module '_pytest.setuponly' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\setuponly.py'>, 'setupplan': <module '_pytest.setupplan' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\setupplan.py'>, 'stepwise': <module '_pytest.stepwise' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\stepwise.py'>, 'warnings': <module '_pytest.warnings' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\warnings.py'>, 'logging': <module '_pytest.logging' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\logging.py'>, 'reports': <module '_pytest.reports' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\reports.py'>, 'faulthandler': <module '_pytest.faulthandler' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\faulthandler.py'>, 'teamcity.pytest_plugin': <module 'teamcity.pytest_plugin' from 'W:\\PyCharm\\helpers\\pycharm\\teamcity\\pytest_plugin.py'>, 'pytester': <module '_pytest.pytester' from 'C:\\Users\\bruno\\pytest\\src\\_pytest\\pytester.py'>, 'hypothesispytest': <module 'hypothesis.extra.pytestplugin' from 'C:\\Users\\bruno\\pytest\\.env36\\lib\\site-packages\\hypothesis\\extra\\pytestplugin.py'>, 'capturemanager': <CaptureManager _method='fd' _global_capturing=<MultiCapture out=<FDCapture 1 oldfd=5 _state='resumed'> err=<FDCapture 2 oldfd=6 _state='resumed'> in_=<FDCapture 0 oldfd=3 _state='started'> _state='resumed' _in_suspended='<UNSET>'> _current_item=<Function test_exit_on_collection_with_maxfail_bigger_than_n_errors>>, 'c:\\users\\bruno.esss.co\\pytest\\testing\\conftest.py': <module 'conftest' from 'c:\\users\\bruno.esss.co\\pytest\\testing\\conftest.py'>, 'session': <Session pytest exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=1>, 'lfplugin': <_pytest.cacheprovider.LFPlugin object at 0x0000010B7DECFA90>, 'nfplugin': <_pytest.cacheprovider.NFPlugin object at 0x0000010B7DECF828>, '1148868949440': <teamcity.pytest_plugin.EchoTeamCityMessages object at 0x0000010B7DECF5C0>, 'stepwiseplugin': <_pytest.stepwise.StepwisePlugin object at 0x0000010B7DECF128>, 'terminalreporter': <_pytest.terminal.TerminalReporter object at 0x0000010B7DECF2B0>, 'logging-plugin': <_pytest.logging.LoggingPlugin object at 0x0000010B7DECF320>, 'funcmanage': <_pytest.fixtures.FixtureManager object at 0x0000010B7E07B208>}

Note that my PyCharm installation is using _jb_pytest_runner.py, differently than yours which is using pytestrunner.py (and I have both scripts in my helpers directory).

I have no idea what might be the problem, and it seems there are already other users facing problems with PyCharm 2019 (PY-37841, PY-36474). You might consider voting on the existing issues and also post yours, in which case please post the link back here so we can vote on it.

@nicoddemus
Copy link
Member

I've also commented on adding more information: https://youtrack.jetbrains.com/issue/PY-37841

Everyone reading this, please vote there if you can (all you need is a google account).

@The-Compiler
Copy link
Member

Everyone reading this, please vote there if you can (all you need is a google account).

Done - note a GitHub account (or Yahoo/Bitbucket/Jetbrains) works as well!

@nicoddemus
Copy link
Member

Thanks!

They move fast, it seems it will be fixed in 2019.2.3 already! ❤️

Closing this now that we have no action on our side.

@maxzheng
Copy link

maxzheng commented Oct 4, 2019

The Jetbrains issue is referring to a different stacktrace, so not sure if that really resolves this one as it didn't work when I tried the patch in the Jetbrains issue.

For this error:

    assert self.invocation_params.args == args
AssertionError

I was able to get it to work by reverting to pytest 5.0.1, so it seems like it's an issue in pytest? 5.1.0 to 5.2.0 didn't work.

@blueyed
Copy link
Contributor

blueyed commented Oct 22, 2019

@maxzheng
Please create a new issue with your details then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

6 participants