Top-level API¶
RSnapshot
¶
Snapshot testing against reference outputs recorded from R.
This object is provided by the r_snapshot fixture. In replay mode, it reads
snapshot files and compares them to Python-generated outputs. In record/auto
modes, it executes the labelled R chunk and writes the snapshot file.
assert_match_text(actual, *, name, ext='.txt', normalize=None, code=None)
¶
Assert that actual matches the expected snapshot content.
path_for(name, *, ext='.txt')
¶
Return the on-disk path for a snapshot.
read_text(name, *, ext='.txt')
¶
Read a text snapshot from disk.
record_text(name, *, ext='.txt', code=None)
¶
Execute the R code for name and write its output as a snapshot.
RSnapshotSettings
dataclass
¶
Configuration for the r-snapshot plugin.
SnapshotMode
¶
Bases: str, Enum
Whether to replay existing snapshots or record new ones.
parse(value)
classmethod
¶
Parse a snapshot mode value from config/CLI.
normalize_newlines(text)
¶
Normalize line endings to \n.
Snapshot files are stored and compared using Unix newlines for determinism.
r_snapshot(name, *, ext='.txt')
¶
Decorator alias for :func:pytest.mark.r_snapshot.
This is a small convenience wrapper around the plugin's marker.
strip_trailing_whitespace(text)
¶
Strip trailing spaces and tabs from each line.