Skip to content

Commit d7eea67

Browse files
committed
testing(fix[diff]): Preserve cell coordinates
why: Snapshot diffs need captured display columns and unambiguous identities for screens inside containers. what: - Preserve ambiguous cell layouts with optional column metadata - Validate complete frames and pair nested screens by typed key paths - Use the Syrupy fallback for unsupported or ordinary values - Cover frame, color and key ambiguity and document snapshot updates
1 parent 7d36b63 commit d7eea67

6 files changed

Lines changed: 1130 additions & 517 deletions

File tree

‎MIGRATION‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ downstream projects (and `>=0.x,<0.y` once `0.1.0` is released).
1414
_Detailed migration steps for the next version will be posted here._
1515
<!-- END PLACEHOLDER - ADD NEW MIGRATION ENTRIES BELOW THIS LINE -->
1616

17+
### Boxed step diffs (#151)
18+
19+
{func}`~libvt.testing.vt_screen` with `diff=` and {fixture}`vt_snapshot` with
20+
`diff=` pair rows at the same viewport index. Container snapshots store VT
21+
frames with supported key paths in separate sections. Frames with ambiguous
22+
display columns record those columns in a footer. Review the diff and
23+
regenerate affected `.ambr` expectations with `pytest --snapshot-update`.
24+
1725
## libvt 0.0.1a2 (2026-11-28)
1826

1927
### Curated PEP 562 `libvt` root exports (#43)

‎docs/topics/testing.md‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ diff highlighters when `ESC` bytes split across color spans.
6363
{func}`~libvt.testing.serialize_vt_snapshot` serializes terminals, snapshots,
6464
{class}`~libvt.screen.Screen` grids, {meth}`~libvt.screen.Screen.region`
6565
slices, {class}`~libvt.contrib.tmux.capture.TmuxCaptureResult` bundles, and
66-
duck-typed pane objects into three plain-text sections:
66+
duck-typed pane objects into these plain-text sections:
6767

6868
1. A canonical metadata header (`size`, `cursor`, `alt`, non-default `modes`).
6969
2. A column-exact Unicode `┌──┐` viewport box read from
7070
{attr}`~libvt.terminal.Terminal.committed`.
71-
3. Run-length `styles:` spans recording `SGR` attributes, 16/256/RGB colors,
71+
3. Optional run-length `styles:` spans recording `SGR` attributes, 16/256/RGB colors,
7272
underline colors, and `OSC 8` hyperlinks.
73+
4. An optional `columns:` footer for rows whose cell boundaries cannot be
74+
recovered from the text and box width alone.
7375

7476
```python
7577
>>> import libvt
@@ -156,9 +158,10 @@ row 1 cols 0..1: '1' -> '2'
156158

157159
### Compact failure diffs
158160

159-
{func}`~libvt.testing.format_vt_diff_lines` leads with `header:`,
160-
`row R cols C0..C1:`, and `styles:` summaries ahead of column-aligned `^`
161-
carets (or ANSI-styled lines when callbacks are supplied):
161+
{func}`~libvt.testing.format_vt_diff_lines` pairs two boxed snapshots by
162+
viewport row. The diff starts with changed header, row and style summaries.
163+
Carets mark changed display columns. Set `color=True` and supply style callbacks
164+
to show colored expected and received lines.
162165

163166
```python
164167
>>> import libvt
@@ -242,6 +245,17 @@ from `pytest --fixtures` when `syrupy` is uninstalled or disabled via
242245
>>> test_worker_row(_CheckAmbr()) # doctest: +HIDE
243246
```
244247

248+
When a dict, list or tuple contains screens, Syrupy labels their diffs with
249+
paths such as `[panes][('logs', 1)]`. Dictionary paths accept built-in strings,
250+
bytes, integers, booleans, finite floats, `None`, and tuples or frozensets of
251+
those keys. The `.ambr` snapshot stores those screens in separate sections.
252+
Paths with other keys, ordinary values, and legacy container snapshots use
253+
Syrupy's line diff.
254+
255+
For independently named assertions, use
256+
`assert vt_screen(left) == vt_snapshot(name="left")` for one screen and
257+
`assert vt_screen(right) == vt_snapshot(name="right")` for the next.
258+
245259
### Project-wide `.ambr` scrubbers
246260

247261
To share scrubbers across every `.ambr` test in a repository, build a memoized

0 commit comments

Comments
 (0)