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

Method test_nested

Lib/test/test_pkgutil.py:581–602  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

579 f.write(contents)
580
581 def test_nested(self):
582 pkgutil_boilerplate = (
583 'import pkgutil; '
584 '__path__ = pkgutil.extend_path(__path__, __name__)')
585 self.create_module('a.pkg.__init__', pkgutil_boilerplate)
586 self.create_module('b.pkg.__init__', pkgutil_boilerplate)
587 self.create_module('a.pkg.subpkg.__init__', pkgutil_boilerplate)
588 self.create_module('b.pkg.subpkg.__init__', pkgutil_boilerplate)
589 self.create_module('a.pkg.subpkg.c', 'c = 1')
590 self.create_module('b.pkg.subpkg.d', 'd = 2')
591 sys.path.insert(0, os.path.join(self.basedir, 'a'))
592 sys.path.insert(0, os.path.join(self.basedir, 'b'))
593 import pkg
594 self.addCleanup(unload, 'pkg')
595 self.assertEqual(len(pkg.__path__), 2)
596 import pkg.subpkg
597 self.addCleanup(unload, 'pkg.subpkg')
598 self.assertEqual(len(pkg.subpkg.__path__), 2)
599 from pkg.subpkg.c import c
600 from pkg.subpkg.d import d
601 self.assertEqual(c, 1)
602 self.assertEqual(d, 2)
603
604
605class ImportlibMigrationTests(unittest.TestCase):

Callers

nothing calls this directly

Calls 5

create_moduleMethod · 0.95
addCleanupMethod · 0.80
insertMethod · 0.45
joinMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected