@@ -17,9 +17,6 @@ def test_ast_import_guard_modules_reuse_shared_import_helper():
1717 violating_modules : list [str ] = []
1818 for module_path in AST_IMPORT_GUARD_MODULES :
1919 module_text = Path (module_path ).read_text (encoding = "utf-8" )
20- if "ast_import_utils import imports_collect_function_sources" not in module_text :
21- violating_modules .append (module_path )
22- continue
2320 if not imports_imports_collect_function_sources (module_text ):
2421 violating_modules .append (module_path )
2522 continue
@@ -30,3 +27,21 @@ def test_ast_import_guard_modules_reuse_shared_import_helper():
3027 violating_modules .append (module_path )
3128
3229 assert violating_modules == []
30+
31+
32+ def test_ast_import_guard_inventory_stays_in_sync_with_helper_imports ():
33+ excluded_modules = {
34+ "tests/test_ast_import_helper_usage.py" ,
35+ "tests/test_ast_import_utils.py" ,
36+ }
37+ discovered_modules : list [str ] = []
38+ for module_path in sorted (Path ("tests" ).glob ("test_*.py" )):
39+ normalized_path = module_path .as_posix ()
40+ if normalized_path in excluded_modules :
41+ continue
42+ module_text = module_path .read_text (encoding = "utf-8" )
43+ if not imports_imports_collect_function_sources (module_text ):
44+ continue
45+ discovered_modules .append (normalized_path )
46+
47+ assert sorted (AST_IMPORT_GUARD_MODULES ) == discovered_modules
0 commit comments