MCPcopy Index your code
hub / github.com/ipython/ipython / _check_smoketest

Method _check_smoketest

tests/test_zzz_autoreload.py:657–853  ·  view source on GitHub ↗

Functional test for the automatic reloader using either '%autoreload 1' or '%autoreload 2'

(self, use_aimport=True)

Source from the content-addressed store, hash-verified

655 assert lo.output == [f"INFO:autoreload:Reloading '{mod_name}'."]
656
657 def _check_smoketest(self, use_aimport=True):
658 """
659 Functional test for the automatic reloader using either
660 '%autoreload 1' or '%autoreload 2'
661 """
662
663 mod_name, mod_fn = self.new_module(
664 """
665x = 9
666
667z = 123 # this item will be deleted
668
669def foo(y):
670 return y + 3
671
672class Baz(object):
673 def __init__(self, x):
674 self.x = x
675 def bar(self, y):
676 return self.x + y
677 @property
678 def quux(self):
679 return 42
680 def zzz(self):
681 '''This method will be deleted below'''
682 return 99
683
684class Bar: # old-style class: weakref doesn't work for it on Python < 2.7
685 def foo(self):
686 return 1
687"""
688 )
689
690 #
691 # Import module, and mark for reloading
692 #
693 if use_aimport:
694 self.shell.magic_autoreload("1")
695 self.shell.magic_aimport(mod_name)
696 stream = StringIO()
697 self.shell.magic_aimport("", stream=stream)
698 self.assertIn(("Modules to reload:\n%s" % mod_name), stream.getvalue())
699
700 with self.assertRaises(ImportError):
701 self.shell.magic_aimport("tmpmod_as318989e89ds")
702 else:
703 self.shell.magic_autoreload("2")
704 self.shell.run_code("import %s" % mod_name)
705 stream = StringIO()
706 self.shell.magic_aimport("", stream=stream)
707 self.assertTrue(
708 "Modules to reload:\nall-except-skipped" in stream.getvalue()
709 )
710 self.assertIn(mod_name, self.shell.ns)
711
712 mod = sys.modules[mod_name]
713
714 #

Callers 2

Calls 5

magic_aimportMethod · 0.80
new_moduleMethod · 0.45
magic_autoreloadMethod · 0.45
run_codeMethod · 0.45
write_fileMethod · 0.45

Tested by

no test coverage detected