File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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"
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments