MCPcopy Index your code
hub / github.com/python/mypy / test_generate_c_function_other_module

Method test_generate_c_function_other_module

mypy/test/teststubgen.py:1258–1271  ·  view source on GitHub ↗

Test that if annotation references type from other module, module will be imported.

(self)

Source from the content-addressed store, hash-verified

1256 assert_equal(gen.get_imports().splitlines(), [])
1257
1258 def test_generate_c_function_other_module(self) -> None:
1259 """Test that if annotation references type from other module, module will be imported."""
1260
1261 def test(arg0: str) -> None:
1262 """
1263 test(arg0: argparse.Action) -> argparse.Action
1264 """
1265
1266 output: list[str] = []
1267 mod = ModuleType(self.__module__, "")
1268 gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod)
1269 gen.generate_function_stub("test", test, output=output)
1270 assert_equal(output, ["def test(arg0: argparse.Action) -> argparse.Action: ..."])
1271 assert_equal(gen.get_imports().splitlines(), ["import argparse"])
1272
1273 def test_generate_c_function_same_module_nested(self) -> None:
1274 """Test that if annotation references type from same module but using full path, no module

Callers

nothing calls this directly

Calls 5

assert_equalFunction · 0.90
splitlinesMethod · 0.80
get_importsMethod · 0.80

Tested by

no test coverage detected