File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,15 @@ def to_module(self) -> tuple[ast.Module, bool]:
290290 )
291291 import_nodes .append (sut_import )
292292
293+ # Create a single empty test case to ensure pytest returns exit code 0
294+ empty_test = PyTestChromosomeToAstVisitor .__create_function_node (
295+ "empty" ,
296+ [ast .Pass ()],
297+ with_self_arg = False ,
298+ is_failing = False ,
299+ )
300+ functions .append (empty_test )
301+
293302 return ast .Module (body = import_nodes + functions , type_ignores = []), coverage_by_import_only
294303
295304
Original file line number Diff line number Diff line change @@ -531,7 +531,7 @@ def test_import_export_no_xfail(
531531
532532
533533def test_coverage_by_import_only (tmp_path : Path ) -> None :
534- """When no test cases exist, SUT is imported with coverage comment and noqa ."""
534+ """When no test cases exist, SUT is imported with coverage comment and an empty test ."""
535535 sut_module_name = "tests.fixtures.accessibles.accessible"
536536 visitor = export .PyTestChromosomeToAstVisitor (sut_module_name = sut_module_name )
537537
@@ -552,3 +552,5 @@ def test_coverage_by_import_only(tmp_path: Path) -> None:
552552 assert "# Importing this module achieves coverage." in content
553553 assert "# noqa: F401" in content
554554 assert "import tests.fixtures.accessibles.accessible" in content
555+ assert "def test_empty():" in content
556+ assert " pass" in content
You can’t perform that action at this time.
0 commit comments