34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import re
|
|
import unittest
|
|
|
|
from repo_checks import ROOT
|
|
|
|
# The one module that may resolve the release root, the Claude home, the config folder and the state folder.
|
|
OWNER = "bin/loop_state/paths.py"
|
|
|
|
# How code spells one of those folders itself, in place of asking OWNER. Prose such as help text, which names `~/.claude` to its reader, is not matched.
|
|
RESOLVED_ELSEWHERE = re.compile(
|
|
r"""["']\.claude["'/]"""
|
|
r"""|["']\.claude-projects["'/]"""
|
|
r"""|["']\.local["'/]"""
|
|
r"""|["']XDG_STATE_HOME["']"""
|
|
r"""|__file__\)\.resolve\(\)\.parents\["""
|
|
)
|
|
|
|
|
|
class PathsInOneModule(unittest.TestCase):
|
|
def test_only_the_paths_module_resolves_the_setups_folders(self) -> None:
|
|
found = [
|
|
f"{path.relative_to(ROOT)}:{number}"
|
|
for path in sorted((ROOT / "bin").rglob("*.py"))
|
|
if not path.name.startswith("test_") and path.relative_to(ROOT).as_posix() != OWNER
|
|
for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1)
|
|
if RESOLVED_ELSEWHERE.search(line)
|
|
]
|
|
|
|
self.assertEqual(found, [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|