-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab492d1
commit 3ce5c0e
Showing
8 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Unit tests.""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Run the resvg-py example.""" | ||
|
||
from __future__ import annotations | ||
|
||
import io | ||
import typing as t | ||
from pathlib import Path | ||
|
||
import pytest | ||
from PIL import Image | ||
|
||
import resvg_py | ||
|
||
if t.TYPE_CHECKING: | ||
from pytest_snapshot.plugin import Snapshot | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"svg_file", | ||
[ | ||
pytest.param("resources/examples/svg/octocat.svg", id="octocat"), | ||
], | ||
) | ||
def test_render(snapshot: Snapshot, svg_file: str) -> None: | ||
options = resvg_py.SVGOptions() | ||
r = resvg_py.Resvg(options) | ||
|
||
with Path(svg_file).open("r") as input_file: | ||
rendered = r.render(input_file.read(), 400, 400) | ||
array = rendered.as_array() | ||
|
||
with io.BytesIO() as png_file: | ||
im = Image.fromarray(array) | ||
im.save(png_file, format="PNG") | ||
snapshot.assert_match(png_file.getvalue(), "output.png") |