Search upward in the directory tree to a maximum of three layers to find and return the package root (containing the 'tests' folder)
(start_path: pathlib.Path)
| 247 | |
| 248 | @positional_deprecated |
| 249 | def find_test_root(start_path: pathlib.Path) -> pathlib.Path: |
| 250 | """ |
| 251 | Search upward in the directory tree to a maximum of three layers |
| 252 | to find and return the package root (containing the 'tests' folder) |
| 253 | """ |
| 254 | cur_path = start_path.resolve() |
| 255 | max_layers = 3 |
| 256 | for _ in range(max_layers): |
| 257 | if (cur_path / "tests" / "test_version_stable.py").exists(): |
| 258 | return cur_path |
| 259 | else: |
| 260 | cur_path = cur_path.parent.resolve() |
| 261 | raise FileNotFoundError( |
| 262 | f"Unable to find package root within {max_layers} upwards" + f"of {start_path}" |
| 263 | ) |
| 264 | |
| 265 | |
| 266 | @positional_deprecated |