@@ -142,7 +142,10 @@ def test(*args: Any, **kwargs: Any) -> None:
142
142
for c in cases :
143
143
if c .error is None :
144
144
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
146
149
assert expected_error not in expected_errors , (
147
150
"collect_cases merges cases into a single stubtest invocation; we already "
148
151
"expect an error for {}" .format (expected_error )
@@ -703,7 +706,12 @@ def h(x: str): ...
703
706
runtime = "" ,
704
707
error = "h" ,
705
708
)
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 = "" )
707
715
yield Case (stub = "" , runtime = "__all__ += ['y']\n y = 5" , error = "y" )
708
716
yield Case (stub = "" , runtime = "__all__ += ['g']\n def g(): pass" , error = "g" )
709
717
# Here we should only check that runtime has B, since the stub explicitly re-exports it
0 commit comments