Module

testing._snapshot

Snapshot capture and comparison.

Functions

strip_ansi 1 str
Remove ANSI escape sequences from text.
def strip_ansi(text: str) -> str
Parameters
Name Type Description
text str
Returns
str
assert_renders 7 str
Render state through template, assert output matches snapshot. If snapshot is …
def assert_renders(state: Any, template: str | Any, *, snapshot: str | Path | None = None, width: int = 80, color: bool = False, update: bool = False, env: Any = None) -> str

Render state through template, assert output matches snapshot.

If snapshot is None, returns rendered string. If snapshot is a path and doesn't exist, creates it. If update=True, overwrites on mismatch.

Parameters
Name Type Description
state Any
template str | Any
snapshot str | Path | None Default:None
width int Default:80
color bool Default:False
update bool Default:False
env Any Default:None
Returns
str
assert_state 4 None
Feed actions through reducer, assert final state matches.
def assert_state(reducer: Any, initial: Any, actions: list | tuple, expected: Any) -> None
Parameters
Name Type Description
reducer Any
initial Any
actions list | tuple
expected Any
assert_saga 2 None
Step through saga, assert each yielded effect matches.
def assert_saga(saga: Any, steps: list[tuple[Any, Any]]) -> None
Parameters
Name Type Description
saga Any
steps list[tuple[Any, Any]]