Skip to content

Commit 77af2bd

Browse files
Synchronize AST import-helper guard inventory with discovered imports
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 2f1e110 commit 77af2bd

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

tests/test_ast_import_helper_usage.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)