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

VSCode Pytest Discovery Fails when using pytest-describe #24661

Open
kassi opened this issue Dec 27, 2024 · 2 comments
Open

VSCode Pytest Discovery Fails when using pytest-describe #24661

kassi opened this issue Dec 27, 2024 · 2 comments
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@kassi
Copy link

kassi commented Dec 27, 2024

Type: Bug

Behaviour

I'm working on a poetry project with pytest and pytest-describe.
Tests are not recognized by the python extension.

My .vscode/settings.json contains

"python.experiments.optInto": ["pythonTestAdapter"],

However, despite setting "Trace" in VSCode Output "Python", there's no "Experiment" in the output.

Steps to reproduce:

  1. Set up a project with pytest-describe.
  2. Configure pytest in pyproject.toml with
[tool.pytest.ini_options]
describe_prefixes = [
    "describe_",
    "when_",
    "with_",
    "without_",
    "if_",
    "unless_",
    "for_",
]
  1. Create test file in tests/convert/test_convert_command.py with nested describe structure, e.g.
def describe_convert_command():
    @pytest.fixture
    def content():
        return None
    @pytest.fixture
    def from_format():
        return None
    @pytest.fixture
    def command(content, from_format):
        return ConvertCommand(content=content, from_format=from_format)
    @pytest.fixture
    def result(command):
        return command.convert()
    def describe_init():
        def with_format_go_licenses():
            @pytest.fixture
            def from_format():
                return "go-licenses"
            def with_valid_invalid_file_format():
                @pytest.fixture
                def content():
                    return inspect.cleandoc("""some key\nsome value""")

                def it_raises_a_value_error(command):
                    with pytest.raises(ValueError):
                        command.convert()

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-12-27 18:19:53.418 [debug] Found cached env for /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:19:53.771 [debug] Testing: Trigger refresh after saving /u/ks/src/myproject/tests/convert/test_convert_command.py
2024-12-27 18:19:54.026 [debug] Delay Trigger[Refresh Test Data]: triggered=12, called=12
2024-12-27 18:19:54.026 [info] Discover tests for workspace name: myproject - uri: /u/ks/src/myproject/tests/convert/test_convert_command.py
2024-12-27 18:19:54.026 [debug] Found cached env for /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:19:54.026 [debug] could not find a pixi interpreter for the interpreter at /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:19:54.028 [debug] Activation Commands received source /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/activate for shell bash, resource /u/ks/src/myproject and interpreter /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:19:54.028 [debug] Activating Environment to capture Environment variables, . /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/printEnvVariables.py
2024-12-27 18:19:54.028 [info] > . ~/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/printEnvVariables.py
2024-12-27 18:19:54.028 [info] shell: bash
2024-12-27 18:19:54.083 [info] > ~/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python ~/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
2024-12-27 18:19:54.083 [info] cwd: .
2024-12-27 18:19:54.366 [error] Error discovering pytest tests:
 n [Error]: ============================= test session starts ==============================
platform darwin -- Python 3.12.4, pytest-8.3.4, pluggy-1.5.0
rootdir: /u/ks/src/myproject
configfile: pyproject.toml
plugins: describe-2.2.0, cov-6.0.0, spec-4.0.0, mock-3.14.0
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: tests/convert/test_convert_command.py::describe_convert_command::describe_init::with_format_go_licenses::with_invalid_file_format::it_raises_a_value_error
kind: ('function', False)
class: Function
name: it_raises_a_value_error
fspath: /u/ks/src/myproject/tests/convert/test_convert_command.py
location: ('tests/convert/test_convert_command.py', 53, 'it_raises_a_value_error')
function: <function describe_convert_command.<locals>.describe_init.<locals>.with_format_go_licenses.<locals>.with_invalid_file_format.<locals>.it_raises_a_value_error at 0x106c56a20>
markers: []
user_properties: []
attrnames: ['_ALLOW_MARKERS', '__abstractmethods__', '__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_check_item_and_collector_diamond_inheritance', '_fixtureinfo', '_getinstance', '_getobj', '_initrequest', '_instance', '_nodeid', '_obj', '_pyfuncitem', '_pytest_diamond_inheritance_warning_shown', '_report_sections', '_repr_failure_py', '_request', '_store', '_traceback_filter', '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', 'iter_parents', 'keywords', 'listchain', 'listextrakeywords', 'listnames', 'location', 'module', 'name', 'nextitem', 'nodeid', 'obj', 'originalname', 'own_markers', 'parent', 'path', 'reportinfo', 'repr_failure', 'runtest', 'session', 'setup', 'stash', 'teardown', 'user_properties', 'warn']

extra info:
fullname: it_raises_a_value_error
testfunc: describe_convert_command.describe_init.with_format_go_licenses.with_invalid_file_format.it_raises_a_value_error
parameterized:

traceback:
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/run_adapter.py", line 18, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/__main__.py", line 96, in main
    parents, result = run(toolargs, **subargs)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 29, in discover
    ec = _pytest_main(pytestargs, [_plugin])
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/config/__init__.py", line 175, in main
    ret: ExitCode | int = config.hook.pytest_cmdline_main(config=config)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 330, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 283, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 336, in _main
    config.hook.pytest_collection(session=session)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 347, in pytest_collection
    session.perform_collect()
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 812, in perform_collect
    hook.pytest_collection_modifyitems(
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 86, in pytest_collection_modifyitems
    test, parents = self.parse_item(item)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 71, in parse_item
    return parse_item(item)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_pytest_item.py", line 182, in parse_item
    raise should_never_reach_here(
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_pytest_item.py", line 130, in should_never_reach_here
    traceback.print_stack()
collected 71 items

<Dir myproject>
  <Package tests>
    <Dir convert>
      <Module test_convert_command.py>
        <DescribeBlock 'describe_convert_command'>
          <DescribeBlock 'describe_init'>
            <DescribeBlock 'with_format_go_licenses'>
              <DescribeBlock 'with_invalid_file_format'>
                <Function it_raises_a_value_error>
              <DescribeBlock 'with_missing_required_fields'>
                <Function it_raises_a_value_error>
              <DescribeBlock 'with_valid_content'>
                <Function it_returns_correct_licenses>
    ...some more modules listed
            <DescribeBlock 'with_whitelisted_package'>
              <Function it_returns_false>
              <Function it_has_warnings>
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: tests/convert/test_convert_command.py::describe_convert_command::describe_init::with_format_go_licenses::with_invalid_file_format::it_raises_a_value_error
kind: ('function', False)
class: Function
name: it_raises_a_value_error
fspath: /u/ks/src/myproject/tests/convert/test_convert_command.py
location: ('tests/convert/test_convert_command.py', 53, 'it_raises_a_value_error')
function: <function describe_convert_command.<locals>.describe_init.<locals>.with_format_go_licenses.<locals>.with_invalid_file_format.<locals>.it_raises_a_value_error at 0x106c56a20>
markers: []
user_properties: []
attrnames: ['_ALLOW_MARKERS', '__abstractmethods__', '__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_check_item_and_collector_diamond_inheritance', '_fixtureinfo', '_getinstance', '_getobj', '_initrequest', '_instance', '_nodeid', '_obj', '_pyfuncitem', '_pytest_diamond_inheritance_warning_shown', '_report_sections', '_repr_failure_py', '_request', '_store', '_traceback_filter', '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', 'iter_parents', 'keywords', 'listchain', 'listextrakeywords', 'listnames', 'location', 'module', 'name', 'nextitem', 'nodeid', 'obj', 'originalname', 'own_markers', 'parent', 'path', 'reportinfo', 'repr_failure', 'runtest', 'session', 'setup', 'stash', 'teardown', 'user_properties', 'warn']

extra info:
fullname: it_raises_a_value_error
testfunc: describe_convert_command.describe_init.with_format_go_licenses.with_invalid_file_format.it_raises_a_value_error
parameterized:

traceback:
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/run_adapter.py", line 18, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/__main__.py", line 96, in main
    parents, result = run(toolargs, **subargs)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 29, in discover
    ec = _pytest_main(pytestargs, [_plugin])
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/config/__init__.py", line 175, in main
    ret: ExitCode | int = config.hook.pytest_cmdline_main(config=config)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 330, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 283, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 336, in _main
    config.hook.pytest_collection(session=session)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 347, in pytest_collection
    session.perform_collect()
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 819, in perform_collect
    hook.pytest_collection_finish(session=self)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 101, in pytest_collection_finish
    test, parents = self.parse_item(item)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 71, in parse_item
    return parse_item(item)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_pytest_item.py", line 182, in parse_item
    raise should_never_reach_here(
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_pytest_item.py", line 130, in should_never_reach_here
    traceback.print_stack()
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 812, in perform_collect
INTERNALERROR>     hook.pytest_collection_modifyitems(
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/cacheprovider.py", line 443, in pytest_collection_modifyitems
INTERNALERROR>     res = yield
INTERNALERROR>           ^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/cacheprovider.py", line 373, in pytest_collection_modifyitems
INTERNALERROR>     res = yield
INTERNALERROR>           ^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 86, in pytest_collection_modifyitems
INTERNALERROR>     test, parents = self.parse_item(item)
INTERNALERROR>                     ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 71, in parse_item
INTERNALERROR>     return parse_item(item)
INTERNALERROR>            ^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_pytest_item.py", line 182, 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 "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 283, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 336, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/logging.py", line 790, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/warnings.py", line 121, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1417, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 347, in pytest_collection
INTERNALERROR>     session.perform_collect()
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/_pytest/main.py", line 819, in perform_collect
INTERNALERROR>     hook.pytest_collection_finish(session=self)
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 101, in pytest_collection_finish
INTERNALERROR>     test, parents = self.parse_item(item)
INTERNALERROR>                     ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 71, in parse_item
INTERNALERROR>     return parse_item(item)
INTERNALERROR>            ^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_pytest_item.py", line 182, in parse_item
INTERNALERROR>     raise should_never_reach_here(
INTERNALERROR> NotImplementedError: Unexpected pytest node (see printed output).

========================= 71 tests collected in 0.07s ==========================

Traceback (most recent call last):
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/run_adapter.py", line 18, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/__main__.py", line 96, in main
    parents, result = run(toolargs, **subargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/testing_tools/adapter/pytest/_discovery.py", line 42, in discover
    raise Exception(f"pytest discovery failed (exit code {ec})")
Exception: pytest discovery failed (exit code 3)

    at ChildProcess.<anonymous> (/u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/src/client/common/process/rawProcessApis.ts:151:29)
    at Object.onceWrapper (node:events:633:26)
    at ChildProcess.emit (node:events:518:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1104:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:518:28)
    at Socket.emit (node:domain:489:12)
    at Pipe.<anonymous> (node:net:343:12)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)
2024-12-27 18:22:04.844 [debug] Found cached env for /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:22:41.199 [debug] Found cached env for /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:23:54.624 [debug] Found cached env for /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:23:54.625 [info] Running installed packages checker:  {
  id: '/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python',
  sysPrefix: '/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12',
  envType: 'Poetry',
  envName: 'myproject-ido50-uZ-py3.12',
  envPath: '/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12',
  path: '/u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python',
  architecture: 3,
  sysVersion: '3.12.4 (main, Aug  1 2024, 08:33:17) [Clang 15.0.0 (clang-1500.3.9.4)]',
  version: {
    raw: '3.12.4',
    major: 3,
    minor: 12,
    patch: 4,
    build: [],
    prerelease: [ 'final', '0' ]
  },
  displayName: "Python 3.12.4 ('myproject-ido50-uZ-py3.12')",
  detailedDisplayName: "Python 3.12.4 ('myproject-ido50-uZ-py3.12': Poetry)",
  type: 'Virtual'
} /u/ks/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/installed_check.py /u/ks/src/myproject/pyproject.toml
2024-12-27 18:23:54.625 [info] > ~/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python ~/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/installed_check.py ./pyproject.toml
2024-12-27 18:23:54.631 [debug] Found cached env for /u/ks/Library/Caches/pypoetry/virtualenvs/myproject-ido50-uZ-py3.12/bin/python
2024-12-27 18:23:54.732 [debug] Installed packages check result:
 []


Extension version: 2024.22.1
VS Code version: Code 1.96.2 (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Darwin arm64 23.4.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.4
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Default
User Settings


venvPath: "<placeholder>"

languageServer: "Pylance"

testing
• pytestEnabled: true
• unittestEnabled: true

terminal
• activateEnvironment: false

experiments
• enabled: false
• optInto: ["pythonTestAdapter"]

Installed Extensions
Extension Name Extension Id Version
Auto Add Brackets in String Interpolation aliariff.auto-add-brackets 0.12.2
autopep8 ms-python.autopep8 2024.0.0
AWS Toolkit amazonwebservices.aws-toolkit-vscode 3.40.0
Better Jinja samuelcolvin.jinjahtml 0.20.0
Binary Plist dnicolson.binary-plist 0.11.4
Character Count stevensona.character-count 0.1.1
chmod dlech.chmod 1.1.1
Code Runner formulahendry.code-runner 0.12.2
CodeSnap adpyke.codesnap 1.3.4
Color Vision wilsonsio.color-vision 0.1.0
Coverage Gutters ryanluker.vscode-coverage-gutters 2.12.0
Dash deerawan.vscode-dash 2.4.0
DeepSource Autofix™ AI DeepSourceCorp.deepsource-vscode 1.6.19
Docker ms-azuretools.vscode-docker 1.29.3
Easy Snippet inu1255.easy-snippet 0.7.5
Edit CSV janisdd.vscode-edit-csv 0.11.1
ESLint dbaeumer.vscode-eslint 3.0.10
Even Better TOML tamasfe.even-better-toml 0.21.2
File Utils sleistner.vscode-fileutils 3.10.3
Flake8 ms-python.flake8 2023.10.0
GitHub Copilot GitHub.copilot 1.254.0
GitHub Copilot Chat GitHub.copilot-chat 0.23.2
GitLens — Git supercharged eamodio.gitlens 16.1.1
HashiCorp Terraform hashicorp.terraform 2.34.2
Increment Selection albymor.increment-selection 0.2.0
IntelliCode VisualStudioExptTeam.vscodeintellicode 1.3.2
IntelliCode API Usage Examples VisualStudioExptTeam.intellicode-api-usage-examples 0.2.9
JavaScript Debugger ms-vscode.js-debug 1.96.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
JSON formatter ClemensPeters.format-json 1.0.3
Jupyter ms-toolsai.jupyter 2024.11.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Keymap ms-toolsai.jupyter-keymap 1.1.2
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.21
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Live Preview ms-vscode.live-server 0.4.15
Live Share ms-vsliveshare.vsliveshare 1.0.5941
Markdown Editor zaaack.markdown-editor 0.1.12
Material Icon Theme PKief.material-icon-theme 5.16.0
MDX unifiedjs.vscode-mdx 1.8.12
MongoDB for VS Code mongodb.mongodb-vscode 1.11.0
New Moon Syntax Theme taniarascia.new-moon-vscode 1.8.8
Notes dionmunk.vscode-notes 1.2.1
Open in SourceTree morrislaptop.vscode-open-in-sourcetree 0.6.0
Prettier - Code formatter esbenp.prettier-vscode 11.0.0
Prettify JSON mohsen1.prettify-json 0.0.3
Project Templates cantonios.project-templates 1.2.0
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.22.1
Python Debugger ms-python.debugpy 2024.14.0
Selected Character Count mousetraps.selected-character-count 0.0.1
shell-format foxundermoon.shell-format 7.2.5
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
Toggle Quotes BriteSnow.vscode-toggle-quotes 0.3.6
TypeScript Toolbox DSKWRK.vscode-generate-getter-setter 0.5.0
VSCode Aider Apertia.vscode-aider 1.0.5
undefined oderwat.indent-rainbow 8.3.1
YAML redhat.vscode-yaml 1.15.0
YAML Sort PascalReitermann93.vscode-yaml-sort 6.6.0
System Info
Item Value
CPUs Apple M3 Pro (11 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 18.00GB (0.05GB free)
Process Argv .
Screen Reader no
VM 0%
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Dec 27, 2024
@kassi
Copy link
Author

kassi commented Dec 29, 2024

@karthiknadig I downgraded to 2024.22.0 and then to 2024.20.0 but my problem still exists with any version. I don't think it's related to the issue you linked.
I don't see a buffer overflow either.

I did some digging and debugging into the extension code and compared it with my output:

    if kind == "function":
        if testfunc and fullname != testfunc + parameterized:
            raise should_never_reach_here(

and

extra info:
fullname: it_raises_a_value_error
testfunc: describe_convert_command.describe_init.with_format_go_licenses.with_invalid_file_format.it_raises_a_value_error
parameterized:

traceback:

fullname is fetched via _get_location from item and item.location contains only it_raises_a_value_error as third element. So to me it looks as if pytest discovery in this case doesn't deliver the required fullname, but some short name only.

Thus I believe it rather has something to do with pytest-describe and the extension not being able to determine them correctly.
WDYT? And would you mind reopening again?
Thanks

@karthiknadig karthiknadig reopened this Dec 29, 2024
@WellingtonNico
Copy link

WellingtonNico commented Dec 30, 2024

@kassi

after downgraded vscode-python extension, I also needed to clone my project to a new folder to get it working again, don't know why, I even upgraded the version again to check if it could be solved only doing this and I needed to clone into a new folder again(also downgrade again), give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants