Repository navigation
test: skip or fix the five tests that fail on PyPy - #851
Merged
Merged
Conversation
Three tests skip on PyPy with the reason stated beside them: a test that expects a Pydantic class made at run time to be freed (pydantic-core keeps it alive there), and one that expects an object to be freed as soon as its last reference goes (PyPy frees it when its garbage collector runs). Two subprocess tests skip with a reference to #708. The test for a signed Pydantic v1 State too deep to restore now uses the deepest State a token can hold, so it is too deep to read back on PyPy as well as on CPython. PyPy reads back more levels than CPython at the same recursion limit, so the earlier 150 levels were readable there. Refs #708 Closes #739 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…nother way The earlier commit made the restore test mint the deepest State a token can hold. That is not reliably too deep on PyPy: its recursion check depends on how warm its JIT is, and after a few dozen restores PyPy reads that State back. So the test skips on PyPy, with the original 150 nodes. A new test makes the restore raise RecursionError itself and checks that the call answers stale_state, so the answer is checked on every interpreter. It fails on CPython and on PyPy when the handler for RecursionError in the restore is removed. Refs #708 Closes #739 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Refs #708
Closes #739
Five tests failed in the weekly PyPy job. Each one now skips on PyPy with the reason beside it, and the
stale_stateanswer for a restore that runs out of frames has its own test that runs on PyPy.Skipped on PyPy
test_a_class_made_at_run_time_can_be_freed(test_events_schemas.py): pydantic-core runs through cpyext (PyPy's emulation of CPython's C interface) and keeps every Pydantic class made at run time alive. Citry cannot change that.test_a_check_that_raises_lets_go_of_the_request_data_without_the_cycle_collector(test_events_pydantic_bounded.py): the test relies on an object being freed as soon as its last reference goes. PyPy has no reference counting and frees objects only when its garbage collector runs. The change for free-threaded CPython from test: make the free-threaded 3.14 tests check what they say #844 is kept.test_the_copy_of_a_chain_of_nested_models_is_built_on_a_thread_with_a_small_stackandtest_deep_data_checked_from_a_thread_with_a_small_stack_is_refused(test_events_pydantic_bounded.py): skipped with the reason "PyPy's C-API layer crashes in this subprocess; see PyPy and free-threaded test failures left after #585 #708".test_a_signed_pydantic_v1_state_too_deep_to_restore_answers_stale_state: the test mints a State 150 nodes deep and expects the restore to run out of Python frames at the default recursion limit. CPython does. PyPy reads that depth back, so the call succeeds. Deeper States do not fix this: on PyPy the depth that runs out of frames changes with how warm its JIT is (a State as deep as a token can hold restored fine after about 10 to 30 earlier restores), so a deep State may or may not run out of frames there.Added
test_a_restore_that_runs_out_of_python_frames_answers_stale_statemakes the State restore raiseRecursionErroritself and checks that the call answers 409stale_state. It checks on every interpreter the rule that the skipped test checks with real depth. Removing theRecursionErrorhandler in_restore_statemakes it fail on CPython and on PyPy. A small helper,_state_reader, builds the component for both tests.Checks
citry_corestubbed, the five skips skip and the new test passes.py--alt-interpreters.yml, started by hand on commit8b8a503ce). Both jobs passed:test (pypy3.11)passed in all 8 batches, andtest (3.14t)passed. The last commit,a3592fc7c, only rewords a skip reason and a comment.Test-only change: it touches nothing the 1.x promise covers, so there is no changelog entry. No value reaches the browser, so the security and advisory-survey passes do not apply.
Checklist
python scripts/check.py; the pull request's own CI runs the gate.🤖 Generated with Claude Code