Commit af58fe2
test: isolate global CONSTANTS collection mutations in conftest
The autouse fixture only snapshotted scalar config attrs, so tests that
mutate a global collection (e.g. CONSTANTS.titles) relied on manual,
non-exception-safe cleanup. If such a test failed before its cleanup ran,
the mutation leaked into later tests — reintroducing the order-dependence
the fixture was meant to eliminate.
Snapshot and restore the collection managers (SetManager / TupleManager /
RegexTupleManager) too, via a small type-aware clone (deepcopy can't
round-trip RegexTupleManager's compiled patterns), and reset the lazy
_pst cache so it recomputes from the restored collections. The manual
cleanup in test_can_change_global_constants is now redundant and removed.
Verified order-independence across randomized seeds and via an injected
test that mutates a global collection then fails before cleanup: the
following test still sees pristine config.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent b68ef39 commit af58fe2
2 files changed
Lines changed: 50 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
22 | 54 | | |
23 | 55 | | |
24 | 56 | | |
| |||
27 | 59 | | |
28 | 60 | | |
29 | 61 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
33 | 66 | | |
34 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
35 | 72 | | |
36 | 73 | | |
37 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
38 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
0 commit comments