Skip to content

Proposal: marker-driven loop/rerun protocol (deep hypothesis integration, pytest-repeat, retries)#14779

Open
RonnyPfannschmidt wants to merge 1 commit into
pytest-dev:mainfrom
RonnyPfannschmidt:proposal/loop-protocol
Open

Proposal: marker-driven loop/rerun protocol (deep hypothesis integration, pytest-repeat, retries)#14779
RonnyPfannschmidt wants to merge 1 commit into
pytest-dev:mainfrom
RonnyPfannschmidt:proposal/loop-protocol

Conversation

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

What

A design document only — no implementation — proposing a first-class test-loop protocol: a marker-carried loop controller (@pytest.mark.loop(controller)) drives repeated executions of one test item with

  • fresh function-scoped fixtures per iteration (setup/teardown cycled through the normal SetupState/FixtureDef paths — no new reset API),
  • intermediate teardown of only the item frame (nextitem is item sentinel + a new SetupState.teardown_item_frame), with the final teardown honoring the real nextitem,
  • per-iteration TestReports carrying a structured loop key (TestReport.loop), usable in junitxml (test_foo[param][key] testcases via (nodeid, workernode, loop_key) keying), the terminal, and machine-readable outputs,
  • deferrable reporting (report="live" | "defer" | "discard") so an engine like hypothesis can run examples silently and report only the shrunk failure.

Why

Anchored to the long-standing threads:

The document includes controller sketches for hypothesis (generate/shrink/minimal-replay), pytest-repeat, and #12939-style retries, the downstream compatibility contract for report consumers, and a list of open questions.

cc @Zac-HD — would value your review of the controller API and the hypothesis sketch in particular: does run_iteration(key, funcargs=..., report=...) plus provides= give the engine everything it needs (generate + shrink + replay-minimal-with-pdb)?


🤖 Generated with Claude Code

A design document (no implementation) for a first-class test-loop
protocol: a marker-carried loop controller drives repeated executions of
one item with fresh function-scoped fixtures per iteration, per-iteration
TestReports carrying structured loop keys (junitxml/xunit-usable), and
deferrable reporting for deep hypothesis integration.

Anchored to pytest-dev#916, pytest-dev#12596/pytest-dev#12597, pytest-dev#12939, pytest-dev#9699 and
HypothesisWorks/hypothesis#377.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@RonnyPfannschmidt
RonnyPfannschmidt requested a review from Zac-HD July 24, 2026 21:50
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.

1 participant