Format dependent tests tree for display.
(
tree: dict,
cpython_prefix: str,
lib_prefix: str,
indent: str = "",
)
| 274 | |
| 275 | |
| 276 | def _format_dependent_tests_tree( |
| 277 | tree: dict, |
| 278 | cpython_prefix: str, |
| 279 | lib_prefix: str, |
| 280 | indent: str = "", |
| 281 | ) -> list[str]: |
| 282 | """Format dependent tests tree for display.""" |
| 283 | from update_lib.deps import is_up_to_date |
| 284 | |
| 285 | lines = [] |
| 286 | module = tree["module"] |
| 287 | tests = tree["tests"] |
| 288 | children = tree["children"] |
| 289 | |
| 290 | if indent == "": |
| 291 | # Root level |
| 292 | # Count total tests in tree |
| 293 | def count_tests(t: dict) -> int: |
| 294 | total = len(t.get("tests", [])) |
| 295 | for c in t.get("children", []): |
| 296 | total += count_tests(c) |
| 297 | return total |
| 298 | |
| 299 | total = count_tests(tree) |
| 300 | if total == 0 and not children: |
| 301 | lines.append(f"\ndependent tests: (no tests depend on {module})") |
| 302 | return lines |
| 303 | lines.append(f"\ndependent tests: ({total} tests)") |
| 304 | |
| 305 | # Check if module is up-to-date |
| 306 | synced = is_up_to_date(module.split(".")[0], cpython_prefix, lib_prefix) |
| 307 | marker = "[x]" if synced else "[ ]" |
| 308 | |
| 309 | # Format this node |
| 310 | if tests: |
| 311 | test_str = " ".join(tests) |
| 312 | if indent == "": |
| 313 | lines.append(f"- {marker} {module}: {test_str}") |
| 314 | else: |
| 315 | lines.append(f"{indent}- {marker} {module}: {test_str}") |
| 316 | elif indent != "" and children: |
| 317 | # Has children but no direct tests |
| 318 | lines.append(f"{indent}- {marker} {module}:") |
| 319 | |
| 320 | # Format children |
| 321 | child_indent = indent + " " if indent else " " |
| 322 | for child in children: |
| 323 | lines.extend( |
| 324 | _format_dependent_tests_tree( |
| 325 | child, cpython_prefix, lib_prefix, child_indent |
| 326 | ) |
| 327 | ) |
| 328 | |
| 329 | return lines |
| 330 | |
| 331 | |
| 332 | def _resolve_module_name( |
no test coverage detected