snapshot utilities¶
tinyvdiff.snapshot
¶
normalize_svg(svg_content)
¶
Normalize SVG content by removing variable content.
Removes metadata and ID attributes that may vary between runs while preserving the visual content of the SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
svg_content
|
str
|
Raw SVG file content as string. |
required |
Returns:
Type | Description |
---|---|
str
|
Normalized SVG content with variable content removed. |
compare_svgs(generated_svg_path, snapshot_svg_path)
¶
Compare two SVG files by their normalized content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
generated_svg_path
|
Path | str
|
Path to the newly generated SVG file. |
required |
snapshot_svg_path
|
Path | str
|
Path to the snapshot SVG file to compare against. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the SVGs match after normalization, False otherwise. |
update_snapshot(generated_svg_path, snapshot_svg_path)
¶
Update or create a snapshot SVG file from a generated SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
generated_svg_path
|
Path | str
|
Path to the source SVG file. |
required |
snapshot_svg_path
|
Path | str
|
Path where the snapshot should be saved. |
required |