Skip to content

test: skip or fix the five tests that fail on PyPy - #851

Merged
JuroOravec merged 3 commits into
mainfrom
test/pypy-skips
Nov 24, 2026
Merged

JuroOravec merged 3 commits into
mainfrom
test/pypy-skips

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

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_state answer 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_stack and test_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_state makes the State restore raise RecursionError itself and checks that the call answers 409 stale_state. It checks on every interpreter the rule that the skipped test checks with real depth. Removing the RecursionError handler in _restore_state makes it fail on CPython and on PyPy. A small helper, _state_reader, builds the component for both tests.

Checks

  • On CPython, both changed files pass (531 tests) and all five original tests run there.
  • On a local macOS PyPy 3.11 with citry_core stubbed, the five skips skip and the new test passes.
  • PyPy job on this branch: run 45296592533 (py--alt-interpreters.yml, started by hand on commit 8b8a503ce). Both jobs passed: test (pypy3.11) passed in all 8 batches, and test (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

  • Tests added or updated for the change. I ran the two changed test files and ruff locally, not the full python scripts/check.py; the pull request's own CI runs the gate.
  • No changelog entry: the change is test-only.
  • No docs change: no behavior or public API changed.
  • No grammar, AST, compiler or binding change.

🤖 Generated with Claude Code

JuroOravec and others added 3 commits November 24, 2026 01:13
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]>
@JuroOravec
JuroOravec merged commit 4c141bd into main Nov 24, 2026
31 checks passed
@JuroOravec
JuroOravec deleted the test/pypy-skips branch November 24, 2026 10:52
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.

Weekly Python tests on PyPy or free-threaded CPython failed

1 participant