Return the top-level module part for a test label.
(label)
| 138 | |
| 139 | |
| 140 | def get_label_module(label): |
| 141 | """Return the top-level module part for a test label.""" |
| 142 | path = Path(label) |
| 143 | if len(path.parts) == 1: |
| 144 | # Interpret the label as a dotted module name. |
| 145 | return label.split(".")[0] |
| 146 | |
| 147 | # Otherwise, interpret the label as a path. Check existence first to |
| 148 | # provide a better error message than relative_to() if it doesn't exist. |
| 149 | if not path.exists(): |
| 150 | raise RuntimeError(f"Test label path {label} does not exist") |
| 151 | path = path.resolve() |
| 152 | rel_path = path.relative_to(RUNTESTS_DIR) |
| 153 | return rel_path.parts[0] |
| 154 | |
| 155 | |
| 156 | def get_filtered_test_modules(start_at, start_after, gis_enabled, test_labels=None): |
no test coverage detected