-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #482 Closes #483 ### Summary of Changes * Use [sypury](https://github.com/tophat/syrupy) snapshot tests for images. Run `pytest --snapshot-update` to update snapshots after changes. * Fix random test failures due to TCL when running tests in a terminal --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
- Loading branch information
1 parent
6443beb
commit 6deddbe
Showing
79 changed files
with
330 additions
and
329 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,35 @@ | ||
from typing import Any | ||
|
||
import matplotlib as mpl | ||
import pytest | ||
from safeds.data.image.containers import Image | ||
from syrupy import SnapshotAssertion | ||
from syrupy.extensions.single_file import SingleFileSnapshotExtension | ||
from syrupy.types import SerializedData | ||
|
||
# Fix for failures when running pytest in a terminal (https://github.com/Safe-DS/Library/issues/482) | ||
mpl.use("agg") | ||
|
||
|
||
class JPEGImageExtension(SingleFileSnapshotExtension): | ||
_file_extension = "jpg" | ||
|
||
def serialize(self, data: Image, **_kwargs: Any) -> SerializedData: | ||
return data._repr_jpeg_() | ||
|
||
|
||
@pytest.fixture() | ||
def snapshot_jpeg(snapshot: SnapshotAssertion) -> SnapshotAssertion: | ||
return snapshot.use_extension(JPEGImageExtension) | ||
|
||
|
||
class PNGImageSnapshotExtension(SingleFileSnapshotExtension): | ||
_file_extension = "png" | ||
|
||
def serialize(self, data: Image, **_kwargs: Any) -> SerializedData: | ||
return data._repr_png_() | ||
|
||
|
||
@pytest.fixture() | ||
def snapshot_png(snapshot: SnapshotAssertion) -> SnapshotAssertion: | ||
return snapshot.use_extension(PNGImageSnapshotExtension) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file added
BIN
+203 KB
...hots__/test_image/TestAddGaussianNoise.test_should_add_noise[minimum noise].png
Oops, something went wrong.
Binary file added
BIN
+480 KB
...apshots__/test_image/TestAddGaussianNoise.test_should_add_noise[some noise].png
Oops, something went wrong.
Binary file added
BIN
+284 KB
...apshots__/test_image/TestAddGaussianNoise.test_should_add_noise[very noisy].png
Oops, something went wrong.
Binary file added
BIN
+8.22 KB
...test_image/TestAdjustBrightness.test_should_adjust_brightness[large factor].png
Oops, something went wrong.
Binary file added
BIN
+151 KB
...test_image/TestAdjustBrightness.test_should_adjust_brightness[small factor].png
Oops, something went wrong.
Binary file added
BIN
+73.4 KB
...s__/test_image/TestAdjustContrast.test_should_adjust_contrast[large factor].png
Oops, something went wrong.
Binary file added
BIN
+181 KB
...s__/test_image/TestAdjustContrast.test_should_adjust_contrast[small factor].png
Oops, something went wrong.
Binary file added
BIN
+139 KB
...rs/__snapshots__/test_image/TestBlur.test_should_return_blurred_image[blur].png
Oops, something went wrong.
Binary file added
BIN
+207 KB
...snapshots__/test_image/TestColorAdjust.test_should_adjust_colors[add color].png
Oops, something went wrong.
Binary file added
BIN
+99.5 KB
...ts__/test_image/TestColorAdjust.test_should_adjust_colors[remove all color].png
Oops, something went wrong.
Binary file added
BIN
+178 KB
...pshots__/test_image/TestColorAdjust.test_should_adjust_colors[remove color].png
Oops, something went wrong.
Binary file added
BIN
+59.4 KB
...pshots__/test_image/TestConvertToGrayscale.test_convert_to_grayscale[plane].png
Oops, something went wrong.
Binary file added
BIN
+5.79 KB
...rs/__snapshots__/test_image/TestCrop.test_should_return_cropped_image[crop].png
Oops, something went wrong.
Binary file added
BIN
+76.8 KB
...ts__/test_image/TestFindEdges.test_should_return_edges_of_image[find_edges].png
Oops, something went wrong.
Binary file added
BIN
+197 KB
...hots__/test_image/TestFlipHorizontally.test_should_flip_horizontally[plane].png
Oops, something went wrong.
Binary file added
BIN
+197 KB
...napshots__/test_image/TestFlipVertically.test_should_flip_vertically[plane].png
Oops, something went wrong.
Binary file added
BIN
+178 KB
...hots__/test_image/TestInvertColors.test_should_invert_colors[invert-colors].png
Oops, something went wrong.
Binary file added
BIN
+205 KB
...age/TestRotate.test_should_return_clockwise_rotated_image[rotate-clockwise].png
Oops, something went wrong.
Binary file added
BIN
+205 KB
...est_should_return_counter_clockwise_rotated_image[rotate-counter-clockwise].png
Oops, something went wrong.
Binary file added
BIN
+262 KB
...ners/__snapshots__/test_image/TestSharpen.test_should_sharpen[large factor].png
Oops, something went wrong.
Binary file added
BIN
+208 KB
...s/__snapshots__/test_image/TestSharpen.test_should_sharpen[negative factor].png
Oops, something went wrong.
Binary file added
BIN
+193 KB
...ners/__snapshots__/test_image/TestSharpen.test_should_sharpen[small factor].png
Oops, something went wrong.
Oops, something went wrong.