MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_run_module_code

Method test_run_module_code

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

Source from the content-addressed store, hash-verified

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