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)
| 54 | |
| 55 | |
| 56 | def 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 | ) |
nothing calls this directly
no test coverage detected