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

Method walk_modules

Lib/test/test___all__.py:78–98  ·  view source on GitHub ↗
(self, basedir, modpath)

Source from the content-addressed store, hash-verified

76 self.assertTrue(dir(sys.modules[modname]))
77
78 def walk_modules(self, basedir, modpath):
79 for fn in sorted(os.listdir(basedir)):
80 path = os.path.join(basedir, fn)
81 if os.path.isdir(path):
82 if fn in SKIP_MODULES:
83 continue
84 pkg_init = os.path.join(path, '__init__.py')
85 if os.path.exists(pkg_init):
86 yield pkg_init, modpath + fn
87 for p, m in self.walk_modules(path, modpath + fn + "."):
88 yield p, m
89 continue
90
91 if fn == '__init__.py':
92 continue
93 if not fn.endswith('.py'):
94 continue
95 modname = fn.removesuffix('.py')
96 if modname in SKIP_MODULES:
97 continue
98 yield path, modpath + modname
99
100 def test_all(self):
101 # List of denied modules and packages

Callers 2

test_allMethod · 0.95
test_no_side_effectsMethod · 0.80

Calls 6

listdirMethod · 0.80
joinMethod · 0.45
isdirMethod · 0.45
existsMethod · 0.45
endswithMethod · 0.45
removesuffixMethod · 0.45

Tested by

no test coverage detected