Skip to content

Make the snapshot marker select tests using only vt_snapshot #87

In review

Description

@tony

Summary

Syrupy’s marker-filtered update returns success with an incorrect terminal golden still on disk. A test that declares only the libvt fixture drops out of the selected set.

Reproduction

  1. From the tagged libvt checkout, install the locked development dependencies with uv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory.

  2. Save the following as case.py at the checkout root.

import subprocess
import sys
from pathlib import Path
from tempfile import TemporaryDirectory

def run(directory, *args):
    cmd = [sys.executable, "-m", "pytest", "-q", "-p", "no:cacheprovider", *args]
    result = subprocess.run(cmd, cwd=directory, capture_output=True, text=True, check=False)
    return result.returncode, result.stdout

with TemporaryDirectory() as directory:
    folder = Path(directory)
    (folder / "test_ticket.py").write_text(
        "from libvt import Terminal\n"
        "from libvt.testing import vt_screen\n"
        "def test_ticket(vt_snapshot):\n"
        "    term = Terminal(rows=1, cols=15)\n"
        "    term.feed(b'APPROVED')\n"
        "    assert vt_screen(term) == vt_snapshot\n"
        "def test_native(snapshot):\n"
        "    assert 'other' == snapshot\n",
        encoding="utf-8",
    )
    assert run(folder, "--snapshot-update")[0] == 0
    golden = next(folder.rglob("*.ambr"))
    before = golden.read_text(encoding="utf-8")
    assert before.count("APPROVED") == 1
    golden.write_text(before.replace("APPROVED", "REJECTED"), encoding="utf-8")
    filtered, log = run(folder, "-m", "syrupy_snapshot", "--snapshot-update")
    direct, _ = run(folder, "test_ticket.py::test_ticket")
    print("filtered exit", filtered, "deselected", "1 deselected" in log,
          "wrong golden retained", "REJECTED" in golden.read_text(encoding="utf-8"), "direct exit", direct)
    assert direct == 0
  1. Run the case.
$ uv run --no-sync python case.py

Expected

A filtered update should select and repair the same terminal golden that fails in a direct comparison.

Actual

The native Syrupy control runs, pytest exits zero, the incorrect golden remains and the affected direct test fails.

Environment

Tested versions

CPython 3.14.6 on Linux ARM64 under WSL2. The example produced the reported result against both v0.0.1a4 and the tested trunk revision.

Evidence

Observed output
filtered exit 0 deselected True wrong golden retained True direct exit 1

Proposal

Make Syrupy’s snapshot fixture visible in the fixture dependency graph or apply its collection marker using a supported hook. Preserve optional installation behavior.

  • Developer experience — A maintainer can use the documented snapshot update command for every terminal test.
  • Immediate benefit — A known-wrong approval is detected and repaired by the filtered command.
  • Longer-term benefit — CI snapshot selection stays consistent across native and libvt extensions.
  • End-user experience — Reviewers can trust a green approval pass when a terminal screen has changed.

References

Activity

  1. added
    bug
    p1
    on Nov 30, 2026
  2. tony commented on Dec 3, 2026

    @tony
    MemberAuthor

    Tests using only vt_snapshot participate in -m syrupy_snapshot updates. With Syrupy 7.0.3 the filtered run updated the VT golden from RIGHT to UPDATED alongside the ordinary Syrupy case, and both passed the unfiltered rerun. PR #189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions