- 시험 · tmp · docs · venv · .claude 의 .py 로 서버가 다시 읽던 것 차단(모듈 폴더 15 개만) - main.py 807 → 541 - test_506_1_reload_scope 신설 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
"""506-1 — 개발 서버 다시 읽기 범위: 시험·tmp .py 는 제외, 모듈 폴더 .py 는 읽음."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from uvicorn.config import Config # noqa: E402
|
|
from uvicorn.supervisors.watchfilesreload import FileFilter # noqa: E402
|
|
|
|
from config.config_dev_server import RELOAD_SKIP, reload_dirs, reload_excludes # noqa: E402
|
|
|
|
|
|
def _filter() -> FileFilter:
|
|
cfg = Config(
|
|
"main:app", reload=True, reload_dirs=reload_dirs(), reload_excludes=reload_excludes()
|
|
)
|
|
return FileFilter(cfg)
|
|
|
|
|
|
def test_제외_목록은_절대_경로_실존_폴더():
|
|
ex = reload_excludes()
|
|
assert ex and all(Path(e).is_absolute() and Path(e).is_dir() for e in ex)
|
|
names = {Path(e).name for e in ex}
|
|
assert {"resources", "tmp", "venv", "docs", ".claude"} <= names
|
|
assert names - {n for n in names if n.startswith(".")} <= RELOAD_SKIP
|
|
|
|
|
|
def test_감시_폴더는_제외_폴더와_안_겹치고_모듈_폴더_15개():
|
|
dirs = reload_dirs()
|
|
assert len(dirs) == 15
|
|
skip = {Path(e) for e in reload_excludes()}
|
|
assert not skip & {Path(d) for d in dirs}
|
|
|
|
|
|
def test_필터_시험_tmp는_안_읽고_모듈_main_config는_읽음():
|
|
f = _filter()
|
|
for rel in ("resources/tester/x.py", "tmp/x.py", "docs/x.py", ".claude/x.py", "venv/Lib/x.py"):
|
|
assert not f(ROOT / rel), rel
|
|
for rel in ("B05_Profile/x.py", "B07_DesignDetail/x.py", "main.py", "config/config_db.py"):
|
|
assert f(ROOT / rel), rel
|