MCPcopy Create free account
hub / github.com/ipython/ipython / test_autoload3_import_Y_as_Z

Method test_autoload3_import_Y_as_Z

tests/test_zzz_autoreload.py:425–447  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

423 self.shell.run_code("assert ext_int == 2")
424
425 def test_autoload3_import_Y_as_Z(self):
426 self.shell.magic_autoreload("3")
427 mod_code = """
428 def func1(): pass
429 n = 1
430 """
431 mod_name, mod_fn = self.new_module(textwrap.dedent(mod_code))
432 self.shell.run_code(f"from {mod_name} import n as foo")
433 self.shell.run_code("foo")
434 with self.assertRaises(NameError):
435 self.shell.run_code("func1()")
436
437 new_code = """
438 n = 100
439 def func2(): pass
440 def func1(): pass
441 m = 5
442 """
443 self.write_file(mod_fn, textwrap.dedent(new_code))
444
445 self.shell.run_code("foo")
446 with self.assertRaises(NameError):
447 self.shell.run_code("n")
448
449 def test_autoload3_import_Y_as_Z_overloading(self):
450 self.shell.magic_autoreload("3")

Callers

nothing calls this directly

Calls 4

magic_autoreloadMethod · 0.45
new_moduleMethod · 0.45
run_codeMethod · 0.45
write_fileMethod · 0.45

Tested by

no test coverage detected