From 2371f1aa3d9af91183c58191c8682c87cebc32f5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 19:14:29 -0600 Subject: [PATCH 1/2] docs(testing): Assert effective palette colors why: A boxed golden can keep its color token while a palette changes. what: - Resolve the token against its committed snapshot appearance. - Check an OSC 4 override and OSC 104 restoration in a doctest. Fixes #105 --- docs/topics/testing.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/topics/testing.md b/docs/topics/testing.md index 24217d26..05bb14d1 100644 --- a/docs/topics/testing.md +++ b/docs/topics/testing.md @@ -90,6 +90,37 @@ styles: r0[6..10]: fg=#ff8c00 ``` +### Assert a palette change + +A boxed golden records the cell's color token, such as `fg=red`. To test +a theme change, read the cell and its palette from the same committed +{class}`~libvt.terminal.Snapshot`. {meth}`~libvt.style.Appearance.resolve_rgb` +returns the color that the palette assigns to that token. + +```python +>>> from libvt import Snapshot, Terminal +>>> from libvt.testing import serialize_vt_snapshot +>>> def foreground(frame: Snapshot) -> tuple[int, int, int]: +... return frame.appearance.resolve_rgb( +... frame[0, 0].style.fg, default_rgb=frame.appearance.fg_rgb +... ) +>>> term = Terminal(rows=1, cols=5) +>>> term.feed(b"\x1b[31mBOARD") +>>> original = term.committed +>>> term.feed(b"\x1b]4;1;#16b3cd\x07") +>>> themed = term.committed +>>> serialize_vt_snapshot(themed) == serialize_vt_snapshot(original) +True +>>> foreground(original), foreground(themed) +((205, 0, 0), (22, 179, 205)) +>>> term.feed(b"\x1b]104;1\x07") +>>> foreground(term.committed) == foreground(original) +True +``` + +For a default-color change, assert `frame.appearance.fg_rgb` or +`frame.appearance.bg_rgb` directly. + ### Scrubbing dynamic values without breaking box borders Naive string replacement shifts right-hand `│` borders whenever a PID, port, or From fe5d1c38e3bc73014841cf17548f49662ab6a696 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 20:00:09 -0600 Subject: [PATCH 2/2] CHANGES(docs): Describe palette-aware assertions why: A golden can contain the same stored color while its resolved display color depends on the snapshot palette. what: - Point to the example that checks the resolved cell color. --- CHANGES | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index ab16d0e2..a98244d3 100644 --- a/CHANGES +++ b/CHANGES @@ -62,6 +62,13 @@ Both errors exit with status 2. `vt_snapshot`. The fixture is also available when the project explicitly loads the Syrupy and libvt plugin modules in `conftest.py`. +### Documentation + +#### Assert effective colors alongside screen goldens (#190) + +The {doc}`/topics/testing` guide shows how to resolve a cell's color +against the palette in its committed snapshot. + ### Development #### Design review and issue skills (#155)