From ee9ad1c56e783832184dbb86b23998c206754f7a Mon Sep 17 00:00:00 2001 From: A5rocks Date: Sun, 21 Dec 2025 16:52:18 +0900 Subject: [PATCH 1/2] Assert that testcases are not empty --- mypy/test/data.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mypy/test/data.py b/mypy/test/data.py index 726076e0c726..7a033f024f9f 100644 --- a/mypy/test/data.py +++ b/mypy/test/data.py @@ -314,6 +314,19 @@ def runtest(self) -> None: # TODO: add a better error message for when someone uses skip and xfail at the same time elif self.xfail: self.add_marker(pytest.mark.xfail) + + if ( + not [line for line in self.input if line.strip()] + and "Empty" not in self.name + and not [ + file + for file in self.files + # these files are added based on other things + if os.path.basename(file[0]) not in ("typing.pyi", "_typeshed.pyi", "builtins.pyi") + ] + ): + raise AssertionError("Empty testcase.") + parent = self.getparent(DataSuiteCollector) assert parent is not None, "Should not happen" suite = parent.obj() From 9dbcbcdb2f07d796402364a60f853aa463d8dd48 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Tue, 23 Dec 2025 13:30:08 +0900 Subject: [PATCH 2/2] Apply suggestion from @A5rocks --- mypy/test/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/test/data.py b/mypy/test/data.py index 7a033f024f9f..30e4ef95adc8 100644 --- a/mypy/test/data.py +++ b/mypy/test/data.py @@ -325,7 +325,7 @@ def runtest(self) -> None: if os.path.basename(file[0]) not in ("typing.pyi", "_typeshed.pyi", "builtins.pyi") ] ): - raise AssertionError("Empty testcase.") + raise AssertionError(f"{self.name} is empty.") parent = self.getparent(DataSuiteCollector) assert parent is not None, "Should not happen"