MCPcopy Create free account
hub / github.com/catboost/catboost / get_proper_module_path

Function get_proper_module_path

library/python/pytest/module_utils.py:56–83  ·  view source on GitHub ↗

Get the file path for a test module relative to the repository root. For synthesized empty __init__.py modules, returns module_name as a fake file path.

(module_name)

Source from the content-addressed store, hash-verified

54
55
56def get_proper_module_path(module_name):
57 """
58 Get the file path for a test module relative to the repository root.
59 For synthesized empty __init__.py modules, returns module_name as a fake file path.
60 """
61 global _BASE_PATHS
62 if _BASE_PATHS is None:
63 _BASE_PATHS = (
64 str(yatest.common.source_path()),
65 str(yatest.common.work_path()),
66 str(yatest.common.build_path()),
67 )
68
69 path = get_module_file_path(module_name)
70
71 if not os.path.isabs(path):
72 if path == module_name:
73 # Synthesized __init__.py module.
74 return None
75 return path
76
77 for base_path in _BASE_PATHS:
78 if is_relative_to(path, base_path):
79 return relative_to(path, base_path)
80
81 raise ValueError(
82 'Failed to resolve module "{}" with path="{}" against known base paths'.format(module_name, path),
83 )

Callers

nothing calls this directly

Calls 5

get_module_file_pathFunction · 0.85
is_relative_toFunction · 0.85
relative_toFunction · 0.85
strClass · 0.50
formatMethod · 0.45

Tested by

no test coverage detected