Skip to main content

Module assert

Module assert 

Source
Expand description

Assertions that fail with a rendered diff: assert_rich_eq!, assert_rich_json_eq!, assert_render_eq! and assert_snapshot_eq!.

The diff is unified unless RICH_ASSERT_LAYOUT=side-by-side. It is coloured only when RICH_ASSERT_COLOR=1, or when stdout is a terminal and CI is unset (RICH_ASSERT_COLOR=0 forces it off). Without colour the output is plain ASCII: -/+/~ markers and a | divider.

Structs§

Report
How a failing assertion renders its diff.

Functions§

assert_json_eq
assert_rich_json_eq!’s body: both values as pretty JSON.
assert_render_eq
assert_render_eq!’s body.
assert_snapshot_eq
assert_snapshot_eq!’s body: the ANSI diff (style-only lines marked ~) and the first differing field.
assert_str_eq
assert_rich_eq!’s body.
render_plain
Render renderable at width through a plain, deterministic target. Trailing whitespace on each line and trailing blank lines are dropped.