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

Method test_run_module_code

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

Source from the content-addressed store, hash-verified

165 self.check_code_execution(create_ns, expected_ns)
166
167 def test_run_module_code(self):
168 mod_name = "<Nonsense>"
169 mod_fname = "Some other nonsense"
170 mod_loader = "Now you're just being silly"
171 mod_package = '' # Treat as a top level module
172 mod_spec = importlib.machinery.ModuleSpec(mod_name,
173 origin=mod_fname,
174 loader=mod_loader)
175 expected_ns = example_namespace.copy()
176 expected_ns.update({
177 "__name__": mod_name,
178 "__file__": mod_fname,
179 "__loader__": mod_loader,
180 "__package__": mod_package,
181 "__spec__": mod_spec,
182 "run_argv0": mod_fname,
183 "run_name_in_sys_modules": True,
184 "module_in_sys_modules": True,
185 })
186 def create_ns(init_globals):
187 return _run_module_code(example_source,
188 init_globals,
189 mod_name,
190 mod_spec)
191 self.check_code_execution(create_ns, expected_ns)
192
193# TODO: Use self.addCleanup to get rid of a lot of try-finally blocks
194class RunModuleTestCase(unittest.TestCase, CodeExecutionMixin):

Callers

nothing calls this directly

Calls 3

check_code_executionMethod · 0.80
copyMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected