Skip to content

test_symbols: reset the session at the end, so its definitions do not leak into other tests - #2048

Merged
rocky merged 2 commits into
masterfrom
fix-test-order-leaks
Oct 18, 2026
Merged

rocky merged 2 commits into
masterfrom
fix-test-order-leaks

Conversation

@tombouctou

Copy link
Copy Markdown
Collaborator

test/builtin/symbol/test_symbols.py sets a = 2, f[x_] := x^2 and g[f] ^:= 2 and leaves them in the session that all the unit tests share. When test/builtin/test_testing_expressions.py runs after it, 8 cases there fail, because Xor[a] becomes Xor[2], EvenQ[f[2]] evaluates f[2], and so on:

pytest test/builtin/symbol/test_symbols.py test/builtin/test_testing_expressions.py
# 8 failed: Xor[a], Xor[a, b], SubsetQ[a + b + c, {1}], SubsetQ[f[a, b, c], f[a]],
#           DisjointQ[{a}], EvenQ[f[2]], OddQ[f[1]], MatchQ[f[2], _?EvenQ]

The usual ordering of the full suite hides this, but other orderings (or a run of a subset of directories) expose it.

The fix adds a (None, None, None, None) case at the end of the list, which resets the session, as in test/test_context.py.

Tests: the two files above now give 119 passed. The full pytest suite gives 0 failures.

🤖 Generated with Claude Code

tombouctou and others added 2 commits October 18, 2026 20:46
…o not leak

test_symbols.py sets a = 2, f[x_] := x^2 and g[f] ^:= 2 and leaves them
in the shared test session. Run before test_testing_expressions.py, it made
8 cases there fail (Xor[a], SubsetQ[f[a, b, c], f[a]], EvenQ[f[2]], ...).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rocky

rocky commented Oct 18, 2026

Copy link
Copy Markdown
Member

LGTM

@rocky
rocky merged commit ef7c7b4 into master Oct 18, 2026
15 checks passed
@rocky
rocky deleted the fix-test-order-leaks branch October 18, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants