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

Method test_run_name

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

Source from the content-addressed store, hash-verified

543 self._check_relative_imports(depth, "__main__")
544
545 def test_run_name(self):
546 depth = 1
547 run_name = "And now for something completely different"
548 pkg_dir, mod_fname, mod_name, mod_spec = (
549 self._make_pkg(example_source, depth))
550 forget(mod_name)
551 expected_ns = example_namespace.copy()
552 expected_ns.update({
553 "__name__": run_name,
554 "__file__": mod_fname,
555 "__package__": mod_name.rpartition(".")[0],
556 "__spec__": mod_spec,
557 })
558 def create_ns(init_globals):
559 return run_module(mod_name, init_globals, run_name)
560 try:
561 self.check_code_execution(create_ns, expected_ns)
562 finally:
563 self._del_pkg(pkg_dir)
564
565 def test_pkgutil_walk_packages(self):
566 # This is a dodgy hack to use the test_runpy infrastructure to test

Callers

nothing calls this directly

Calls 7

_make_pkgMethod · 0.95
_del_pkgMethod · 0.95
forgetFunction · 0.90
check_code_executionMethod · 0.80
copyMethod · 0.45
updateMethod · 0.45
rpartitionMethod · 0.45

Tested by

no test coverage detected