Skip to content

Commit 512fb4f

Browse files
Add imports-from-module helper import boundary guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 6989bb5 commit 512fb4f

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ This runs lint, format checks, compile checks, tests, and package build.
9797
- `tests/test_ast_import_helper_usage.py` (shared AST import-helper usage enforcement across AST import-boundary guard suites),
9898
- `tests/test_ast_import_utils.py` (shared AST import-helper contract validation),
9999
- `tests/test_ast_import_utils_module_import_boundary.py` (shared AST import-helper module import boundary enforcement across test modules),
100+
- `tests/test_ast_module_import_helper_import_boundary.py` (shared AST module-import helper import boundary enforcement across test modules),
100101
- `tests/test_binary_file_open_helper_usage.py` (shared binary file open helper usage enforcement),
101102
- `tests/test_browser_use_payload_helper_usage.py` (browser-use payload helper usage enforcement),
102103
- `tests/test_ci_workflow_quality_gates.py` (CI guard-stage + make-target enforcement),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"tests/test_ast_import_helper_usage.py",
2727
"tests/test_ast_import_utils.py",
2828
"tests/test_ast_import_utils_module_import_boundary.py",
29+
"tests/test_ast_module_import_helper_import_boundary.py",
2930
"tests/test_guardrail_ast_utils.py",
3031
"tests/test_helper_transport_usage_boundary.py",
3132
"tests/test_manager_model_dump_usage.py",

tests/test_ast_import_utils_module_import_boundary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"tests/test_ast_call_symbol_helper_import_boundary.py",
1919
"tests/test_ast_import_helper_import_boundary.py",
2020
"tests/test_ast_import_helper_secondary_import_boundary.py",
21+
"tests/test_ast_module_import_helper_import_boundary.py",
2122
"tests/test_ast_import_utils.py",
2223
"tests/test_ast_import_utils_module_import_boundary.py",
2324
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
from tests.ast_import_utils import imports_symbol_from_module
6+
7+
pytestmark = pytest.mark.architecture
8+
9+
10+
EXPECTED_IMPORTS_FROM_MODULE_IMPORTERS = (
11+
"tests/test_ast_import_utils.py",
12+
"tests/test_ast_import_utils_module_import_boundary.py",
13+
)
14+
15+
16+
def test_imports_from_module_imports_are_centralized():
17+
discovered_modules: list[str] = []
18+
for module_path in sorted(Path("tests").glob("test_*.py")):
19+
module_text = module_path.read_text(encoding="utf-8")
20+
if not imports_symbol_from_module(
21+
module_text,
22+
module="tests.ast_import_utils",
23+
symbol="imports_from_module",
24+
):
25+
continue
26+
discovered_modules.append(module_path.as_posix())
27+
28+
assert discovered_modules == list(EXPECTED_IMPORTS_FROM_MODULE_IMPORTERS)

0 commit comments

Comments
 (0)