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

Method _get_directory_containing_module

Lib/unittest/loader.py:342–352  ·  view source on GitHub ↗
(self, module_name)

Source from the content-addressed store, hash-verified

340 return self.suiteClass(tests)
341
342 def _get_directory_containing_module(self, module_name):
343 module = sys.modules[module_name]
344 full_path = os.path.abspath(module.__file__)
345
346 if os.path.basename(full_path).lower().startswith('__init__.py'):
347 return os.path.dirname(os.path.dirname(full_path))
348 else:
349 # here we have been given a module rather than a package - so
350 # all we can do is search the *same* directory the module is in
351 # should an exception be raised instead
352 return os.path.dirname(full_path)
353
354 def _get_name_from_path(self, path):
355 if path == self._top_level_dir:

Callers 1

discoverMethod · 0.95

Calls 5

abspathMethod · 0.45
startswithMethod · 0.45
lowerMethod · 0.45
basenameMethod · 0.45
dirnameMethod · 0.45

Tested by

no test coverage detected