Skip to content

Commit 896220f

Browse files
Add default open-prefix literal boundary guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent d7a111d commit 896220f

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ This runs lint, format checks, compile checks, tests, and package build.
138138
- `tests/test_file_message_default_constant_import_boundary.py` (extension/session file-message default constant import boundary enforcement),
139139
- `tests/test_file_message_default_constant_usage.py` (extension/session file-message default-prefix constant usage enforcement),
140140
- `tests/test_file_message_prefix_literal_boundary.py` (extension/session file-message prefix literal centralization in shared metadata modules),
141+
- `tests/test_file_open_default_prefix_literal_boundary.py` (shared default open-file prefix literal centralization in `hyperbrowser/client/file_utils.py`),
141142
- `tests/test_file_open_error_helper_import_boundary.py` (shared file-open error-message helper import boundary enforcement),
142143
- `tests/test_file_open_error_helper_usage.py` (shared file-open error-message helper usage enforcement),
143144
- `tests/test_file_path_display_helper_import_boundary.py` (shared file-path display helper import boundary enforcement),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"tests/test_model_request_wrapper_internal_reuse.py",
5151
"tests/test_tool_mapping_reader_usage.py",
5252
"tests/test_display_helper_usage.py",
53+
"tests/test_file_open_default_prefix_literal_boundary.py",
5354
"tests/test_file_message_default_constant_import_boundary.py",
5455
"tests/test_file_message_default_constant_usage.py",
5556
"tests/test_file_message_prefix_literal_boundary.py",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
HYPERBROWSER_ROOT = Path(__file__).resolve().parents[1] / "hyperbrowser"
9+
ALLOWED_LITERAL_MODULE = Path("client/file_utils.py")
10+
DEFAULT_OPEN_PREFIX_LITERAL = "Failed to open file at path"
11+
12+
13+
def test_default_open_prefix_literal_is_centralized_in_file_utils():
14+
violations: list[str] = []
15+
16+
for module_path in sorted(HYPERBROWSER_ROOT.rglob("*.py")):
17+
relative_path = module_path.relative_to(HYPERBROWSER_ROOT)
18+
if relative_path == ALLOWED_LITERAL_MODULE:
19+
continue
20+
module_text = module_path.read_text(encoding="utf-8")
21+
if DEFAULT_OPEN_PREFIX_LITERAL not in module_text:
22+
continue
23+
violations.append(relative_path.as_posix())
24+
25+
assert violations == []

0 commit comments

Comments
 (0)