should_never_reach_here for particular test case when parametrized test has unmatched brackets or parenthesis
See original GitHub issueEnvironment data
- VS Code version: 1.62.0-insider
- Extension version (available under the Extensions sidebar): Python v2021.10.1317843341
- OS and version: Windows_NT x64 10.0.19043
- Python version (& distribution if applicable, e.g. Anaconda): 3.8.0
- Type of virtual environment used: N/A
- Value of the
python.languageServer
setting: Pylance
Expected behaviour
Non-fatal test discovery.
Actual behaviour
Runtime error causes test discovery to fail.
Steps to reproduce:
@pytest.mark.parametrize("test_input,expected",
[
# Some tests,
("spaces](www", "spaces](www"),
# Some other tests,
]
)
def test_remove_markdown_links(test_input, expected):
# My implementation
Commenting out the above test case removes the symptoms of the bug.
Logs
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: ./deployment/tests/test_text_helper.py::test_remove_markdown_links[spaces](www-spaces](www]
traceback:
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
main(tool, cmd, subargs, toolargs)
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main
parents, result = run(toolargs, **subargs)
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 30, in discover
ec = _pytest_main(pytestargs, [_plugin])
File "/home/eric/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 162, in main
ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/eric/.local/lib/python3.8/site-packages/_pytest/main.py", line 316, in pytest_cmdline_main
return wrap_session(config, _main)
File "/home/eric/.local/lib/python3.8/site-packages/_pytest/main.py", line 269, in wrap_session
session.exitstatus = doit(config, session) or 0
File "/home/eric/.local/lib/python3.8/site-packages/_pytest/main.py", line 322, in _main
config.hook.pytest_collection(session=session)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/eric/.local/lib/python3.8/site-packages/_pytest/main.py", line 333, in pytest_collection
session.perform_collect()
File "/home/eric/.local/lib/python3.8/site-packages/_pytest/main.py", line 641, in perform_collect
hook.pytest_collection_finish(session=self)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/eric/.local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 107, in pytest_collection_finish
test, parents = self.parse_item(item)
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item
return parse_item(item)
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 161, in parse_item
(nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 144, in <lambda>
_parse_node_id=(lambda *a: _parse_node_id(*a)),
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 382, in _parse_node_id
testid, name, kind = next(nodes)
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 479, in _iter_nodes
raise should_never_reach_here(
File "/home/eric/.vscode-server/extensions/ms-python.python-2021.10.1317843341/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 132, in should_never_reach_here
traceback.print_stack()
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to access the string in brackets used in parametrized ...
I am trying to find out how this method __repr__ is defined, in order to access directly the string test_example[2-test-3] from which I...
Read more >Parametrizing tests — pytest documentation
pytest allows to easily parametrize test functions. ... to select specific cases to run, and they will also identify the specific case when...
Read more >Check for Balanced Brackets in an expression (well ...
Given an expression string, write a program to examine whether the pairs and the orders of parentheses are balanced in expression or not....
Read more >Is there an equivalent of `M-x check-parens` for finding ...
Check for unbalanced parentheses in the current buffer. ... The behavior of check-parens is mode-specific. As its doc says, it checks for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mjpieters We have plans replacing this test adapter entirely, there are several issues with the current test adapter. This will be a temporary solution for this issue.
As a workaround, you can use
pytest.param
to override the node ID for the problematic test (reference):also, FWIW:
Not a misspelling - English just happens to have four valid spellings of that word. pytest-parawtf to the rescue! (no, please don’t use it in production…)