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

Pytest node issue during test discovery #18048

Closed
1 task done
Deladox opened this issue Nov 17, 2021 · 1 comment
Closed
1 task done

Pytest node issue during test discovery #18048

Deladox opened this issue Nov 17, 2021 · 1 comment
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug

Comments

@Deladox
Copy link

Deladox commented Nov 17, 2021

VS Code version

1.62.2

Extension version

v2021.11.1422169775

OS type

Linux

OS version

Ubuntu 20.04.3 LTS

Python distribution

Operating system

Python version

3.8.10

Language server

Pylance

Expected behaviour

Tests should have been discovered automatically

Actual behaviour

The Python extension ran into an unexpected situation while processing a pytest node during test discovery.

Steps to reproduce

Probably hard to reproduce and I cannot share files due to secret codes not available for public

Logs

nodeid: ./tests/common/snmp/test_snmp_cli.py::test_snmp_sysname_invalid[x]x]

traceback:
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/run_adapter.py", line 22, in
main(tool, cmd, subargs, toolargs)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/main.py", line 100, in main
parents, result = run(toolargs, **subargs)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 30, in discover
ec = _pytest_main(pytestargs, [_plugin])
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/config/init.py", line 79, in main
return config.hook.pytest_cmdline_main(config=config)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in call
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 242, in pytest_cmdline_main
return wrap_session(config, _main)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 209, in wrap_session
session.exitstatus = doit(config, session) or 0
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 248, in _main
config.hook.pytest_collection(session=session)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in call
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 258, in pytest_collection
return session.perform_collect()
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 500, in perform_collect
hook.pytest_collection_finish(session=self)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in call
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 107, in pytest_collection_finish
test, parents = self.parse_item(item)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
return parse_item(item)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 161, in parse_item
(nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in
_parse_node_id=(lambda *a: _parse_node_id(*a)),
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 382, in _parse_node_id
testid, name, kind = next(nodes)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 479, in _iter_nodes
raise should_never_reach_here(
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/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 "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 496, in perform_collect
INTERNALERROR> hook.pytest_collection_modifyitems(
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in call
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 92, in pytest_collection_modifyitems
INTERNALERROR> test, parents = self.parse_item(item)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
INTERNALERROR> return parse_item(item)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 161, in parse_item
INTERNALERROR> (nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in
INTERNALERROR> _parse_node_id=(lambda *a: _parse_node_id(*a)),
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 382, in _parse_node_id
INTERNALERROR> testid, name, kind = next(nodes)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 479, in _iter_nodes
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 "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 209, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 248, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in call
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 258, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/_pytest/main.py", line 500, in perform_collect
INTERNALERROR> hook.pytest_collection_finish(session=self)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in call
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/kalle/sota-1/venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 107, in pytest_collection_finish
INTERNALERROR> test, parents = self.parse_item(item)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
INTERNALERROR> return parse_item(item)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 161, in parse_item
INTERNALERROR> (nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in
INTERNALERROR> _parse_node_id=(lambda *a: _parse_node_id(*a)),
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 382, in _parse_node_id
INTERNALERROR> testid, name, kind = next(nodes)
INTERNALERROR> File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 479, in _iter_nodes
INTERNALERROR> raise should_never_reach_here(
INTERNALERROR> NotImplementedError: Unexpected pytest node (see printed output).

===================== 1 warnings, 4 error in 28.79 seconds =====================

Traceback (most recent call last):
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/run_adapter.py", line 22, in
main(tool, cmd, subargs, toolargs)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/adapter/main.py", line 100, in main
parents, result = run(toolargs, **subargs)
File "/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/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)

at ChildProcess.<anonymous> (/home/kalle/.vscode-server/extensions/ms-python.python-2021.11.1422169775/out/client/extension.js:17:38446)
at Object.onceWrapper (events.js:422:26)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)]

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Deladox Deladox added bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Nov 17, 2021
@karthiknadig karthiknadig added area-testing triage and removed triage-needed Needs assignment to the proper sub-team labels Nov 17, 2021
@kimadeline
Copy link

Hello @Deladox, thank you for reaching out.

The way we currently parse the test discovery output is very brittle, and we are currently in the process of reworking that. Closing in favor of #17242.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants