MCPcopy Index your code
hub / github.com/python/cpython / test_package_imported_no_warning

Method test_package_imported_no_warning

Lib/test/test_runpy.py:495–508  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 7

_make_pkgMethod · 0.95
run_moduleFunction · 0.90
__import__Function · 0.85
addCleanupMethod · 0.80
assertInMethod · 0.80
assertWarnsRegexMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected