Files
agent-zero/tests/test_import_cycles.py
linkliti a7cec50656 fix(helpers): defer the files import in strings to break the import cycle
helpers.strings imported helpers.files at module level while helpers.files imports sanitize_string back from helpers.strings mid-file, so any module importing helpers.strings before helpers.files failed with a partially initialized module error; the strings module now imports files inside replace_file_includes, its only consumer, keeping module-level strings imports safe codebase-wide.

Validation: pytest tests/test_import_cycles.py tests/test_tool_action_contracts.py
2026-10-21 23:37:32 +03:00

17 lines
393 B
Python

import subprocess
import sys
from pathlib import Path
def test_strings_module_imports_before_files():
repo_root = Path(__file__).resolve().parents[1]
result = subprocess.run(
[sys.executable, "-c", "import helpers.strings; import helpers.files"],
cwd=repo_root,
capture_output=True,
text=True,
)
assert result.returncode == 0, result.stderr