Test that if annotation references type from other module, module will be imported.
(self)
| 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 |
nothing calls this directly
no test coverage detected