Issue #17211: Yield a namedtuple in pkgutil.

Patch by Ramchandra Apte.
This commit is contained in:
Eric Snow 2016-09-07 18:37:17 -07:00
parent 8e7cdb2586
commit d5f9223981
5 changed files with 35 additions and 21 deletions

View file

@ -577,13 +577,14 @@ from ..uncle.cousin import nephew
self.addCleanup(self._del_pkg, pkg_dir)
for depth in range(2, max_depth+1):
self._add_relative_modules(pkg_dir, "", depth)
for finder, mod_name, ispkg in pkgutil.walk_packages([pkg_dir]):
self.assertIsInstance(finder,
for moduleinfo in pkgutil.walk_packages([pkg_dir]):
self.assertIsInstance(moduleinfo, pkgutil.ModuleInfo)
self.assertIsInstance(moduleinfo.module_finder,
importlib.machinery.FileFinder)
if ispkg:
expected_packages.remove(mod_name)
if moduleinfo.ispkg:
expected_packages.remove(moduleinfo.name)
else:
expected_modules.remove(mod_name)
expected_modules.remove(moduleinfo.name)
self.assertEqual(len(expected_packages), 0, expected_packages)
self.assertEqual(len(expected_modules), 0, expected_modules)