(self)
| 493 | self._del_pkg(pkg_dir) |
| 494 | |
| 495 | def test_package_imported_no_warning(self): |
| 496 | pkg_dir, _, mod_name, _ = self._make_pkg("", 1, "__main__") |
| 497 | self.addCleanup(self._del_pkg, pkg_dir) |
| 498 | package = mod_name.replace(".__main__", "") |
| 499 | # No warning should occur if we only imported the parent package |
| 500 | __import__(package) |
| 501 | self.assertIn(package, sys.modules) |
| 502 | with warnings.catch_warnings(): |
| 503 | warnings.simplefilter("error", RuntimeWarning) |
| 504 | run_module(package) |
| 505 | # But the warning should occur if we imported the __main__ submodule |
| 506 | __import__(mod_name) |
| 507 | with self.assertWarnsRegex(RuntimeWarning, r"found in sys\.modules"): |
| 508 | run_module(package) |
| 509 | |
| 510 | def test_run_package_in_namespace_package(self): |
| 511 | for depth in range(1, 4): |
nothing calls this directly
no test coverage detected