Commit aecdd4e
test(conftest): isolate polish cache per test, harden API-key delete (#32)
Two related test-isolation gaps that surfaced as snapshot flakes:
1. The autouse polish fixture set ``ATTUNE_AUTHOR_STRICT_POLISH=false``
and deleted ``ANTHROPIC_API_KEY``, but did not redirect
``ATTUNE_AUTHOR_POLISH_CACHE``. Every test shared the dev machine's
real ``~/.attune/polish_cache``. A prior live ``regenerate`` run
would populate the cache with polished output; subsequent
golden-snapshot tests would then observe LLM-rewritten content
instead of the deterministic Jinja fallback, depending on which
tests had run before — flaky between machines and between
sessions on the same machine. Point the cache at a per-session
tmp directory via ``tmp_path_factory``.
2. ``monkeypatch.delenv`` raised ``KeyError`` when the var was not
already set — fragile across environments. Use
``raising=False``.
Repro of the flake (on a dev machine with ``.env`` carrying a live
key and ``~/.attune/polish_cache`` populated from a real run):
pytest tests/test_generated_templates_golden.py
# FAILED test_task_template_matches_snapshot — snapshot shows raw
# Jinja output, observed value is the LLM-polished rewrite
After this commit, the test suite is hermetic w.r.t. polish state
regardless of the host's cache or env.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 3de9323 commit aecdd4e
1 file changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
24 | 36 | | |
25 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
26 | 42 | | |
27 | 43 | | |
28 | 44 | | |
29 | | - | |
30 | | - | |
| 45 | + | |
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
| |||
0 commit comments