Skip to content

unexpected situation while processing a pytest node during test discovery #19804

Closed

Description

@csgehman

Type: Bug

Behaviour

Expected vs. Actual

Expect the extension to discover pytest test functions. Instead, it reports an "unexpected situation".

Steps to reproduce:

  1. Enable pytest testing.
  2. Point test discovery at a specific test module by specifying a relative path with "python.testing.pytestArgs": ["test/unit/test_baseline.py"].
  3. Run "Refresh Tests" command.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

Sanitized Python extension output:

> ./venv/fireball/bin/python3 ~/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear test/unit/test_baseline.py
cwd: .
[ERROR 2022-8-8 16:59:23.15]: Error discovering pytest tests:
 [n [Error]: ============================= test session starts ==============================
platform linux -- Python 3.9.6, pytest-5.4.3, py-1.11.0, pluggy-0.13.1
rootdir: /home/ /local/gitRepos/fireball
plugins: cov-2.5.1
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_baseline_trace

extra info:
fileid:   

traceback:
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/__main__.py", line 99, in main
    parents, result = run(toolargs, **subargs)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 30, in discover
    ec = _pytest_main(pytestargs, [_plugin])
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/config/__init__.py", line 124, in main
    ret = config.hook.pytest_cmdline_main(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 240, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 191, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 246, in _main
    config.hook.pytest_collection(session=session)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 257, in pytest_collection
    return session.perform_collect()
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 454, in perform_collect
    hook.pytest_collection_modifyitems(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 92, in pytest_collection_modifyitems
    test, parents = self.parse_item(item)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
    return parse_item(item)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 173, in parse_item
    (nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in <lambda>
    _parse_node_id=(lambda *a: _parse_node_id(*a)),
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 396, in _parse_node_id
    testid, name, kind = next(nodes)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 460, in _iter_nodes
    nodeid, testid = _normalize_test_id(testid, kind)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 455, in <lambda>
    _normalize_test_id=(lambda *a: _normalize_test_id(*a)),
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 526, in _normalize_test_id
    raise should_never_reach_here(
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 132, in should_never_reach_here
    traceback.print_stack()
collected 1 item
<Module test_baseline.py>
  <Function test_baseline_trace>
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_baseline_trace

extra info:
fileid:   

traceback:
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/__main__.py", line 99, in main
    parents, result = run(toolargs, **subargs)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 30, in discover
    ec = _pytest_main(pytestargs, [_plugin])
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/config/__init__.py", line 124, in main
    ret = config.hook.pytest_cmdline_main(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 240, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 191, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 246, in _main
    config.hook.pytest_collection(session=session)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 257, in pytest_collection
    return session.perform_collect()
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 458, in perform_collect
    hook.pytest_collection_finish(session=self)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 107, in pytest_collection_finish
    test, parents = self.parse_item(item)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
    return parse_item(item)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 173, in parse_item
    (nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in <lambda>
    _parse_node_id=(lambda *a: _parse_node_id(*a)),
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 396, in _parse_node_id
    testid, name, kind = next(nodes)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 460, in _iter_nodes
    nodeid, testid = _normalize_test_id(testid, kind)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 455, in <lambda>
    _normalize_test_id=(lambda *a: _normalize_test_id(*a)),
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 526, in _normalize_test_id
    raise should_never_reach_here(
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/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/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 454, in perform_collect
INTERNALERROR>     hook.pytest_collection_modifyitems(
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 92, in pytest_collection_modifyitems
INTERNALERROR>     test, parents = self.parse_item(item)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
INTERNALERROR>     return parse_item(item)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 173, in parse_item
INTERNALERROR>     (nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in <lambda>
INTERNALERROR>     _parse_node_id=(lambda *a: _parse_node_id(*a)),
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 396, in _parse_node_id
INTERNALERROR>     testid, name, kind = next(nodes)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 460, in _iter_nodes
INTERNALERROR>     nodeid, testid = _normalize_test_id(testid, kind)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 455, in <lambda>
INTERNALERROR>     _normalize_test_id=(lambda *a: _normalize_test_id(*a)),
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 526, in _normalize_test_id
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/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 191, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 246, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 257, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/_pytest/main.py", line 458, in perform_collect
INTERNALERROR>     hook.pytest_collection_finish(session=self)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/timTheEnchanter/local/gitRepos/fireball/venv/fireball/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 107, in pytest_collection_finish
INTERNALERROR>     test, parents = self.parse_item(item)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
INTERNALERROR>     return parse_item(item)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 173, in parse_item
INTERNALERROR>     (nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in <lambda>
INTERNALERROR>     _parse_node_id=(lambda *a: _parse_node_id(*a)),
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 396, in _parse_node_id
INTERNALERROR>     testid, name, kind = next(nodes)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 460, in _iter_nodes
INTERNALERROR>     nodeid, testid = _normalize_test_id(testid, kind)
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 455, in <lambda>
INTERNALERROR>     _normalize_test_id=(lambda *a: _normalize_test_id(*a)),
INTERNALERROR>   File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 526, in _normalize_test_id
INTERNALERROR>     raise should_never_reach_here(
INTERNALERROR> NotImplementedError: Unexpected pytest node (see printed output).

============================ no tests ran in 1.35s =============================

Traceback (most recent call last):
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/adapter/__main__.py", line 99, in main
    parents, result = run(toolargs, **subargs)
  File "/home/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/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/timTheEnchanter/.vscode-server/extensions/ms-python.python-2022.14.0/out/client/extension.js:2:240364)
	at Object.onceWrapper (node:events:646:26)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)]

User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

terminal
• activateEnvironment: false

Extension version: 2022.14.0
VS Code version: Code 1.71.0 (784b0177c56c607789f9638da7b6bf3230d47a8c, 2022-09-01T07:25:38.437Z)
OS version: Darwin x64 21.6.0
Modes:
Sandboxed: No
Remote OS version: Linux x64 3.10.0-957.1.3.el7.x86_64

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30557515
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
pylanb8912:30545647
vsclangdc:30486549
c4g48928:30535728
hb751961:30553087
dsvsc012cf:30540253
azure-dev_surveyone:30548225
i497e931:30553904

Activity

  1. karthiknadig commented on Sep 9, 2022

    @karthiknadig
    Member

    csgehman Can you provide the test code that generated this? also, could you share your test settings?

  2. added
    info-neededIssue requires more information from poster
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Sep 9, 2022
  3. csgehman commented on Sep 12, 2022

    @csgehman
    Author

    The code is not public. Here's a sanitized version of test_baseline.py:

    from utils import DATA
    from fireball.io.trace import TraceReader
    import fireball.baseliner as baseline
    import matplotlib.pyplot as plt
    import numpy as np
    
    
    def test_baseline_trace(do_plots=False):
        """
        Test baseline estimation.
    
        Args:
            do_plots: Set to true to bring up some matplotlib plots.
                Note these do not get written to disk - these are for
                viewing in PyCharm (IMHO). If you leave this true after grokking the plots,
                it is conceivable that this test might do ... something odd when run from
                the command line, although it typically will not.
        """
        
        # private code eliminated
    
        if do_plots:
            # plot the extracted baseline mean and sigma
            plt.figure()
            x = range(0, 2000)
            plt.plot(trace[x], 'b', zorder=1)
            plt.plot(baseline_est.mean[x], 'r', zorder=2)
            upper = baseline_est.mean + baseline_est.sigma
            lower = baseline_est.mean - baseline_est.sigma
            plt.fill_between(x, lower[x], upper[x], alpha=0.5, zorder=3, facecolor='LightGreen')
            plt.xlabel('frame (' + str(test_trc_name) + ')')
            plt.ylabel('DN')
            plt.title('baseline estimation')
            plt.show()
    

    I'm not sure what you mean by "test settings". Here are the python.testing things in my settings.json:

    {
        "python.testing.pytestArgs": [
            // "--no-cov",
            "test/unit/test_baseline.py"
        ],
        "python.testing.unittestEnabled": false,
        "python.testing.pytestEnabled": true,
    }
    

    I just noticed the extraneous , in this JSON, but removing it doesn't appear to have any impact.

  4. eleanorjboyd commented on Dec 14, 2022

    @eleanorjboyd
    Member

    Hello, this looks to be a bug in the test adapter and is likely related to the ongoing buggy behavior on pytest discovery and running in vscode. We are currently work on a rewrite of how pytest works in vscode and hope this rewrite will fix this and similar bugs. The main issue which will be working on is here: #17242, and progress will be updated on this issue. Thank you!

  5. plafosse commented on Jan 9, 2023

    @plafosse

    Are there any known workarounds, I've been wanting to use this feature since it came out but its never been able to discover the tests.

  6. eleanorjboyd commented on Jan 10, 2023

    @eleanorjboyd
    Member

    Peter LaFosse (@plafosse), could you provide more information on your situation specifically? Since it is a general error code I am not sure any workarounds unless I see what more specifically you are running into. Settings and logs would be helpful to diagnose- thanks!

  7. eleanorjboyd commented on Jun 22, 2023

    @eleanorjboyd
    Member

    Hello! We have just finished our testing rewrite and are beginning the roll out to users. I have tested this issue with the re-write and I am no longer reproducing the bug! If you would like to try it yourself, you need to be on vscode insiders and then add this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"]. We are in the process of switching all users to the rewrite but are doing so incrementally so if you do not have insiders, watch our release notes to get updated on when it will begin to hit stable. Let me know if it doesn’t work for you and we can re-open this issue. Thanks!

  8. eleanorjboyd commented on Jun 26, 2023

    @eleanorjboyd
    Member

    verification steps same as repro steps:

    1. Enable pytest testing by adding this to your settings: "python.experiments.optInto": ["pythonTestAdapter"],
    2. Point test discovery at a specific test module by specifying a relative path with "python.testing.pytestArgs": ["test/unit/test_baseline.py"].
    3. Run "Refresh Tests" command & make sure it locates the test correctly

    example for what could be in your test file:

    def test_this():
        assert True
    
  9. rzhao271 commented on Jun 28, 2023

    @rzhao271

    The Refresh Tests command does nothing for me. I added the setting to my User settings file. Am I supposed to press the Configure Python Tests button first? There's also a single info log that shows up saying that it's discovering tests, but no trace or debug logs seem to appear after.

    macOS
    Python extension v2023.11.11791005

    Edit: I just noticed I didn't enable the pytestEnabled setting. Will see if that fixes it.

  10. rzhao271 commented on Jun 28, 2023

    @rzhao271

    The extension discovered the test in test/unit/test_easy.py now, but I got stuck a few times.

    1. I forgot to set python.testing.pytestEnabled to true.
    2. I knew I needed to create an environment (because I made a new repository), but then I forgot to install pytest into it.
    3. After installing pytest, the extension discovered the test.

    I'm guessing the usual flow is to press the "Configure Python Tests" button, still? I feel like I took a much more manual approach this time.

  11. eleanorjboyd commented on Jun 28, 2023

    @eleanorjboyd
    Member

    Hi! Sorry for the ongoing confusion. Yes, it will work best to do Configure Python Tests as this will set the python.testing.pytestEnabled to true. The current flow we think for our users is they have a repo with tests or just wrote them, they click on the test explorer icon, follow the prompts to setup their testing with Configure Python Tests then discovery should work. By the time they get to the test explorer we expect them to already have pytest installed since they will be using it in their workspace already or have it listed as a dependency. Hope this clarification helps and let me know what is still confusing you as I am thinking about how to update this flow in the future and would love any input. Thanks!

  12. locked as resolved and limited conversation to collaborators on Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bugverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions