Skip to content

Commit 30b2a2d

Browse files
authored
Assert that testcases are not empty (#20453)
I've seen new contributors make this mistake, though I can't find a PR as an example.
1 parent 99a140f commit 30b2a2d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mypy/test/data.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,19 @@ def runtest(self) -> None:
314314
# TODO: add a better error message for when someone uses skip and xfail at the same time
315315
elif self.xfail:
316316
self.add_marker(pytest.mark.xfail)
317+
318+
if (
319+
not [line for line in self.input if line.strip()]
320+
and "Empty" not in self.name
321+
and not [
322+
file
323+
for file in self.files
324+
# these files are added based on other things
325+
if os.path.basename(file[0]) not in ("typing.pyi", "_typeshed.pyi", "builtins.pyi")
326+
]
327+
):
328+
raise AssertionError(f"{self.name} is empty.")
329+
317330
parent = self.getparent(DataSuiteCollector)
318331
assert parent is not None, "Should not happen"
319332
suite = parent.obj()

0 commit comments

Comments
 (0)