From ff0d4df88c9aa612853b5bd43cce65440a7ce0ec Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Wed, 4 Oct 2023 10:34:14 -0700 Subject: [PATCH] handle key error pytest (#22151) fixes https://github.com/microsoft/vscode-python/issues/22149 --- pythonFiles/vscode_pytest/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonFiles/vscode_pytest/__init__.py b/pythonFiles/vscode_pytest/__init__.py index e870136e3dc1..2fab4d77c2f8 100644 --- a/pythonFiles/vscode_pytest/__init__.py +++ b/pythonFiles/vscode_pytest/__init__.py @@ -200,8 +200,9 @@ def pytest_report_teststatus(report, config): elif report.failed: report_value = "failure" message = report.longreprtext - node_path = map_id_to_path[report.nodeid] - if not node_path: + try: + node_path = map_id_to_path[report.nodeid] + except KeyError: node_path = cwd # Calculate the absolute test id and use this as the ID moving forward. absolute_node_id = get_absolute_test_id(report.nodeid, node_path)