Skip to content

Concept: Replay a failed pytest terminal screen offline - #139

Draft
tony wants to merge 6 commits into
masterfrom
concept/pytest-replay
Draft

tony wants to merge 6 commits into
masterfrom
concept/pytest-replay

Conversation

@tony

@tony tony commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Save failing vt_terminal, vt_factory, and POSIX vt_pty tests with pytest --vt-replay-dir=DIR.
  • Locate the first differing cell, including written spaces hidden by box padding.
  • Replay incoming bytes and resizes offline with python -m libvt replay FILE.

A terminal can narrow for a single draw and finish at its original size. The replay file retains the resize order and checks the resulting dimensions, visible text, wrap flags, styles, and cursor. Use fixed fixture dimensions and environment for a controlled PTY capture. An incomplete capture still includes the observed rows and any available assertion difference. Closes #136.

Closes #117

Refs #127.

Try it

Run the deliberately failing example from a libvt checkout. Pytest prints the saved JSON path in the failure report.

$ gh pr checkout 139 && uv run --frozen --all-groups --all-extras pytest -q examples/replay_prompt.py --vt-replay-dir=.vt-replays

Run uv run python -m libvt replay followed by the JSON path to inspect the saved screen. The first difference reports a written space at row 0, column 4.

Test plan

  • Fail a real PTY test and find startup output, a resize, and the child's receipt in order.
  • Replay a Linux capture with one-byte feeds. The earlier PR review also recorded a native Windows replay.
  • Remove the resize or startup bytes and observe replay verification fail. Change only a style and check that replay reports the mismatch.
  • Check fallback output for a plain assertion, unsupported configuration, and capture limits.
  • Run the full suite, Ruff, ty, and Sphinx with warnings treated as errors.

why: A terminal recording needs its resize order to reproduce a failed
     screen.

what:
- Save bounded pytest failure traces with ordered bytes and resizes
- Identify the first differing cell in literal screen assertions
- Replay fixture and POSIX PTY failures from a saved artifact
tony added 5 commits December 2, 2026 20:43
why: Give readers of a concept branch the option name and local guide.

what:
- Link to the guide in the same revision as the README.
why: A published package may predate the example under review.

what:
- Give readers the command that loads the source revision.
why: Readers need a failure that generates an artifact on first use.

what:
- Run the same example from the guide and the replay regression.
- Show where the written trailing space appears in the saved screen.
why: A replay needs enough evidence to tell an exact frame from an
     incomplete or invalid trace.

what:
- Record fixture setup and replayable configuration with ordered
  terminal events
- Check frame contents, held geometry and parser limits during replay
- Report available screen differences when input cannot be replayed
- Exercise altered traces and document the fixture controls
why: Record the branch's user-visible change in the unreleased notes.

what:
- Add the #139 entry under What's new in CHANGES
- Add the #139 entry under Fixes in CHANGES
@tony
tony force-pushed the concept/pytest-replay branch from 7dda244 to 07463a6 Compare December 3, 2026 02:54

This branch was successfully deployed

1 active deployment
docs — 07463a66 Deployed Dec 3, 2026 by tony via build (3.14) #296
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.

Save failed pytest terminal screens for offline replay Show the hidden difference when terminal assertion boxes match

1 participant