Skip to content

pytest plugin

tinyvdiff.pytest_plugin

TinyVDiff

Helper class for visual regression testing with PDFs.

__init__(request)

Initialize TinyVDiff with configuration from pytest.

assert_pdf_snapshot(pdf_path, snapshot_name)

Assert that a PDF matches its stored snapshot.

Converts each page of the PDF to SVG and compares it with stored snapshots, updating the snapshots if requested via --tinyvdiff-update.

Parameters:

Name Type Description Default
pdf_path Path | str

Path to the PDF file to test.

required
snapshot_name str

Base name for the snapshot files. For multi-page PDFs, page number will be inserted before file extension. For example, a two-page test.pdf becomes test_p1.svg and test_p2.svg.

required

Raises:

Type Description
Failed

If snapshots do not match and updates are not enabled.

tinyvdiff(request)

Pytest fixture providing TinyVDiff functionality.

Parameters:

Name Type Description Default
request FixtureRequest

Pytest fixture request object.

required

Returns:

Type Description
TinyVDiff

Configured TinyVDiff instance for the current test.

pytest_addoption(parser)

Add tinyvdiff command line options to pytest.

Parameters:

Name Type Description Default
parser Parser

pytest command line parser to extend.

required