Resolve a test name to its library group from DEPENDENCIES. Args: test_name: Test name with or without test_ prefix (e.g., "test_urllib2" or "urllib2") Returns: Library name if test belongs to a group, None otherwise
(test_name: str)
| 771 | |
| 772 | |
| 773 | def resolve_test_to_lib(test_name: str) -> str | None: |
| 774 | """Resolve a test name to its library group from DEPENDENCIES. |
| 775 | |
| 776 | Args: |
| 777 | test_name: Test name with or without test_ prefix (e.g., "test_urllib2" or "urllib2") |
| 778 | |
| 779 | Returns: |
| 780 | Library name if test belongs to a group, None otherwise |
| 781 | """ |
| 782 | # Normalize: add test_ prefix if not present |
| 783 | if not test_name.startswith("test_"): |
| 784 | test_name = f"test_{test_name}" |
| 785 | |
| 786 | for lib_name, dep_info in DEPENDENCIES.items(): |
| 787 | tests = dep_info.get("test", []) |
| 788 | for test_path in tests: |
| 789 | # test_path is like "test_urllib2.py" or "test_multiprocessing_fork" |
| 790 | path_stem = test_path.removesuffix(".py") |
| 791 | if path_stem == test_name: |
| 792 | return lib_name |
| 793 | |
| 794 | return None |
| 795 | |
| 796 | |
| 797 | # Test-specific dependencies (only when auto-detection isn't enough) |
no test coverage detected