question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support pytest plugins

See original GitHub issue

Environment data

  • VS Code version: 1.59.0-insider
  • Extension version (available under the Extensions sidebar): v2021.7.1060902895
  • OS and version: macOS 10.15.7
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): pipenv
  • Value of the python.languageServer setting: Default

Expected behaviour

It discovers tests

Actual behaviour

The Python extension has run into an unexpected situation while processing a pytest node during test discovery. Please Please open an issue at: https://github.com/microsoft/vscode-python/issues and paste the following output there.

nodeid: test/views/test_stations.py::describe_get_stations_with_count::describe_loggernet_data_platform::data_platform::it_queries_station_count kind: (‘function’, False) class: Function name: data_platform::it_queries_station_count fspath: /Users/dan/groundwork/GroundNetEngine/test/views/test_stations.py location: (‘test/views/test_stations.py’, 42, ‘describe_get_stations_with_count.describe_loggernet_data_platform.data_platform::it_queries_station_count’) function: <function describe_get_stations_with_count.<locals>.data_platform.<locals>.it_queries_station_count at 0x106ad3d30> markers: [] user_properties: [] attrnames: [‘_ALLOW_MARKERS’, ‘annotations’, ‘class’, ‘delattr’, ‘dict’, ‘dir’, ‘doc’, ‘eq’, ‘format’, ‘ge’, ‘getattribute’, ‘gt’, ‘hash’, ‘init’, ‘init_subclass’, ‘le’, ‘lt’, ‘module’, ‘ne’, ‘new’, ‘reduce’, ‘reduce_ex’, ‘repr’, ‘setattr’, ‘sizeof’, ‘slots’, ‘str’, ‘subclasshook’, ‘weakref’, ‘_fixtureinfo’, ‘_getobj’, ‘_initrequest’, ‘_nodeid’, ‘_obj’, ‘_prunetraceback’, ‘_pyfuncitem’, ‘_report_sections’, ‘_repr_failure_py’, ‘_request’, ‘_store’, ‘add_marker’, ‘add_report_section’, ‘addfinalizer’, ‘cls’, ‘config’, ‘extra_keyword_matches’, ‘fixturenames’, ‘from_parent’, ‘fspath’, ‘funcargs’, ‘function’, ‘get_closest_marker’, ‘getmodpath’, ‘getparent’, ‘ihook’, ‘instance’, ‘iter_markers’, ‘iter_markers_with_node’, ‘keywords’, ‘listchain’, ‘listextrakeywords’, ‘listnames’, ‘location’, ‘module’, ‘name’, ‘nextitem’, ‘nodeid’, ‘obj’, ‘originalname’, ‘own_markers’, ‘parent’, ‘reportinfo’, ‘repr_failure’, ‘runtest’, ‘session’, ‘setup’, ‘teardown’, ‘user_properties’, ‘warn’]

extra info: fullname: describe_get_stations_with_count.describe_loggernet_data_platform.data_platform::it_queries_station_count testfunc: describe_get_stations_with_count.describe_loggernet_data_platform.data_platform.it_queries_station_count parameterized:

traceback: File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/run_adapter.py”, line 22, in <module> main(tool, cmd, subargs, toolargs) File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/main.py”, line 100, in main parents, result = run(toolargs, **subargs) File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 30, in discover ec = _pytest_main(pytestargs, [_plugin]) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/config/init.py”, line 162, in main ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main( File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in <lambda> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall res = hook_impl.function(*args) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 316, in pytest_cmdline_main return wrap_session(config, _main) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 269, in wrap_session session.exitstatus = doit(config, session) or 0 File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 322, in _main config.hook.pytest_collection(session=session) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in <lambda> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall res = hook_impl.function(*args) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 333, in pytest_collection session.perform_collect() File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 641, in perform_collect hook.pytest_collection_finish(session=self) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in <lambda> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall res = hook_impl.function(*args) File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 107, in pytest_collection_finish test, parents = self.parse_item(item) File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 77, in parse_item return parse_item(item) File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py”, line 172, in parse_item raise should_never_reach_here( File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py”, line 132, in should_never_reach_here traceback.print_stack() INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 637, in perform_collect INTERNALERROR> hook.pytest_collection_modifyitems( INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in <lambda> INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 208, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 80, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 92, in pytest_collection_modifyitems INTERNALERROR> test, parents = self.parse_item(item) INTERNALERROR> File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 77, in parse_item INTERNALERROR> return parse_item(item) INTERNALERROR> File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py”, line 172, in parse_item INTERNALERROR> raise should_never_reach_here( INTERNALERROR> NotImplementedError: Unexpected pytest node (see printed output). INTERNALERROR> INTERNALERROR> During handling of the above exception, another exception occurred: INTERNALERROR> INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 269, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 322, in _main INTERNALERROR> config.hook.pytest_collection(session=session) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in <lambda> INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 208, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 80, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 333, in pytest_collection INTERNALERROR> session.perform_collect() INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/_pytest/main.py”, line 641, in perform_collect INTERNALERROR> hook.pytest_collection_finish(session=self) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in <lambda> INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 208, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 80, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File “/Users/dan/.local/share/virtualenvs/GroundNetEngine-WLpcZVa5/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 107, in pytest_collection_finish INTERNALERROR> test, parents = self.parse_item(item) INTERNALERROR> File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 77, in parse_item INTERNALERROR> return parse_item(item) INTERNALERROR> File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py”, line 172, in parse_item INTERNALERROR> raise should_never_reach_here( INTERNALERROR> NotImplementedError: Unexpected pytest node (see printed output).

========================= 22 tests collected in 4.56s ==========================

Traceback (most recent call last): File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/run_adapter.py”, line 22, in <module> main(tool, cmd, subargs, toolargs) File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/main.py”, line 100, in main parents, result = run(toolargs, **subargs) File “/Users/dan/.vscode-insiders/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 44, in discover raise Exception(“pytest discovery failed (exit code {})”.format(ec)) Exception: pytest discovery failed (exit code 3)

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kr-hansencommented, Feb 22, 2022

Will note that in the meantime, this same problem can be solved by pinning pytest-describe==2.0.0 in the environment for testing. For some reason VSCode only breaks with pytest-describe==2.0.1

1reaction
karthiknadigcommented, Nov 24, 2021

@roeap We are currently working on this. https://github.com/microsoft/vscode-python/issues/17242 an objective with the re-write of the test adapter is to allow it to work with other plugins.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugin List — pytest documentation
name summary last release status requi... pytest‑accept A pytest‑plugin for updating doctest outputs Jan 07, 2022 N/A pytes... pytest‑addons‑test 用于测试pytest的插件 Aug 02, 2021 N/A pytes... pytest‑aio...
Read more >
Pytest Plugins to Love - Towards Data Science
17 Specialized Plugins — You'll know if you need them ; pytest-cookie : Supports testing of cookiecutter templates. ; pytest-plt and pytest-mpl : ......
Read more >
7 pytest Plugins You Must Definitely Use - miguendes's blog
1. pytest-mock · 2. pytest-cov · 3. pytest-django · 4. pytest-asyncio · 5. pytest-randomly · 6. pytest-clarity · 7. pytest-bdd.
Read more >
Writing plugins — pytest documentation
A plugin contains one or multiple hook functions. Writing hooks explains the basics and details of how you can write a hook function...
Read more >
8 great pytest plugins - Opensource.com
1. pytest-sugar · 2. pytest-cov · 3. pytest-picked · 4. pytest-instafail · 5. pytest-tldr · 6. pytest-xdist · 7. pytest-django · 8. django-test-plus...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found