Skip to content

Commit 07d1883

Browse files
committed
updates
1 parent c7b66fe commit 07d1883

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

python_files/tests/unittestadapter/test_discovery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ def test_empty_discovery() -> None:
191191
actual = discover_tests(start_dir, pattern, None)
192192

193193
assert actual["status"] == "success"
194-
assert "tests" in actual
194+
# When no tests are found, the tests key should not be present in the payload
195+
assert "tests" not in actual
195196
assert "error" not in actual
196197

197198

python_files/unittestadapter/discovery.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ def discover_tests(
9191
except Exception:
9292
error.append(traceback.format_exc())
9393

94-
# Still include the tests in the payload even if there are errors so that the TS
95-
# side can determine if it is from run or discovery.
96-
payload["tests"] = tests if tests is not None else None
94+
# Only include tests in the payload if tests were discovered.
95+
# If no tests found (tests is None), omit the tests key per the docstring contract.
96+
if tests is not None:
97+
payload["tests"] = tests
9798

9899
if len(error):
99100
payload["status"] = "error"

python_files/unittestadapter/pvsc_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ def build_test_tree(
281281
} # concatenate class name and function test name
282282
current_node["children"].append(test_node)
283283

284+
# If no tests were discovered, return None instead of an empty root node
285+
if not root["children"]:
286+
return None, error
287+
284288
return root, error
285289

286290

0 commit comments

Comments
 (0)