Skip to content

Commit 0757335

Browse files
committed
Add test
1 parent 4adeace commit 0757335

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mypy/test/teststubtest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def test(*args: Any, **kwargs: Any) -> None:
142142
for c in cases:
143143
if c.error is None:
144144
continue
145-
expected_error = "{}.{}".format(TEST_MODULE_NAME, c.error)
145+
if c.error:
146+
expected_error = "{}.{}".format(TEST_MODULE_NAME, c.error)
147+
else:
148+
expected_error = TEST_MODULE_NAME
146149
assert expected_error not in expected_errors, (
147150
"collect_cases merges cases into a single stubtest invocation; we already "
148151
"expect an error for {}".format(expected_error)
@@ -703,7 +706,12 @@ def h(x: str): ...
703706
runtime="",
704707
error="h",
705708
)
706-
yield Case(stub="", runtime="__all__ = []", error=None) # dummy case
709+
# __all__ present at runtime, but not in stub -> error
710+
yield Case(stub="", runtime="__all__ = []", error="__all__")
711+
# If runtime has __all__ but stub does not,
712+
# we should raise an error with the module name itself
713+
# if there are any names defined in the stub that are not in the runtime __all__
714+
yield Case(stub="_Z = int", runtime="", error="")
707715
yield Case(stub="", runtime="__all__ += ['y']\ny = 5", error="y")
708716
yield Case(stub="", runtime="__all__ += ['g']\ndef g(): pass", error="g")
709717
# Here we should only check that runtime has B, since the stub explicitly re-exports it

0 commit comments

Comments
 (0)