6
6
from safeds .data .image .typing import ImageFormat
7
7
from safeds .data .tabular .containers import Table
8
8
from safeds .exceptions import OutOfBoundsError
9
+ from syrupy import SnapshotAssertion
9
10
10
11
from tests .helpers import resolve_resource_path
11
12
@@ -236,7 +237,7 @@ class TestConvertToGrayscale:
236
237
["image/plane.png" ],
237
238
ids = ["plane" ],
238
239
)
239
- def test_convert_to_grayscale (self , resource_path : str , snapshot_png ) -> None :
240
+ def test_convert_to_grayscale (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
240
241
image = Image .from_png_file (resolve_resource_path (resource_path ))
241
242
assert image .convert_to_grayscale () == snapshot_png
242
243
@@ -264,7 +265,7 @@ class TestFlipVertically:
264
265
["image/plane.png" ],
265
266
ids = ["plane" ],
266
267
)
267
- def test_should_flip_vertically (self , resource_path : str , snapshot_png ) -> None :
268
+ def test_should_flip_vertically (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
268
269
image = Image .from_png_file (resolve_resource_path (resource_path ))
269
270
assert image .flip_vertically () == snapshot_png
270
271
@@ -280,7 +281,7 @@ class TestFlipHorizontally:
280
281
["image/plane.png" ],
281
282
ids = ["plane" ],
282
283
)
283
- def test_should_flip_horizontally (self , resource_path : str , snapshot_png ) -> None :
284
+ def test_should_flip_horizontally (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
284
285
image = Image .from_png_file (resolve_resource_path (resource_path ))
285
286
assert image .flip_horizontally () == snapshot_png
286
287
@@ -295,11 +296,11 @@ class TestAdjustContrast:
295
296
("resource_path" , "factor" ),
296
297
[
297
298
("image/plane.png" , 0.75 ),
298
- ("image/plane.png" , 5 )
299
+ ("image/plane.png" , 5 ),
299
300
],
300
- ids = ["small factor" , "large factor" ]
301
+ ids = ["small factor" , "large factor" ],
301
302
)
302
- def test_should_adjust_contrast (self , resource_path : str , factor : float , snapshot_png ) -> None :
303
+ def test_should_adjust_contrast (self , resource_path : str , factor : float , snapshot_png : SnapshotAssertion ) -> None :
303
304
image = Image .from_png_file (resolve_resource_path (resource_path ))
304
305
assert image .adjust_contrast (factor ) == snapshot_png
305
306
@@ -323,11 +324,11 @@ class TestAdjustBrightness:
323
324
("resource_path" , "factor" ),
324
325
[
325
326
("image/plane.png" , 0.5 ),
326
- ("image/plane.png" , 10 )
327
+ ("image/plane.png" , 10 ),
327
328
],
328
- ids = ["small factor" , "large factor" ]
329
+ ids = ["small factor" , "large factor" ],
329
330
)
330
- def test_should_adjust_brightness (self , resource_path : str , factor : float , snapshot_png ) -> None :
331
+ def test_should_adjust_brightness (self , resource_path : str , factor : float , snapshot_png : SnapshotAssertion ) -> None :
331
332
image = Image .from_png_file (resolve_resource_path (resource_path ))
332
333
assert image .adjust_brightness (factor ) == snapshot_png
333
334
@@ -352,7 +353,7 @@ class TestInvertColors:
352
353
["image/plane.png" ],
353
354
ids = ["invert-colors" ],
354
355
)
355
- def test_should_invert_colors (self , resource_path : str , snapshot_png ) -> None :
356
+ def test_should_invert_colors (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
356
357
image = Image .from_png_file (resolve_resource_path (resource_path ))
357
358
assert image .invert_colors () == snapshot_png
358
359
@@ -367,7 +368,7 @@ class TestColorAdjust:
367
368
],
368
369
ids = ["add color" , "remove color" , "remove all color" ],
369
370
)
370
- def test_should_adjust_colors (self , resource_path : str , factor : float , snapshot_png ) -> None :
371
+ def test_should_adjust_colors (self , resource_path : str , factor : float , snapshot_png : SnapshotAssertion ) -> None :
371
372
image = Image .from_png_file (resolve_resource_path (resource_path ))
372
373
assert image .adjust_color_balance (factor ) == snapshot_png
373
374
@@ -410,7 +411,9 @@ class TestAddGaussianNoise:
410
411
],
411
412
ids = ["minimum noise" , "some noise" , "very noisy" ],
412
413
)
413
- def test_should_add_noise (self , resource_path : str , standard_deviation : float , snapshot_png ) -> None :
414
+ def test_should_add_noise (
415
+ self , resource_path : str , standard_deviation : float , snapshot_png : SnapshotAssertion
416
+ ) -> None :
414
417
image = Image .from_png_file (resolve_resource_path (resource_path ))
415
418
assert image .add_gaussian_noise (standard_deviation ) == snapshot_png
416
419
@@ -435,7 +438,7 @@ class TestBlur:
435
438
["image/plane.png" ],
436
439
ids = ["blur" ],
437
440
)
438
- def test_should_return_blurred_image (self , resource_path : str , snapshot_png ) -> None :
441
+ def test_should_return_blurred_image (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
439
442
image = Image .from_png_file (resolve_resource_path (resource_path ))
440
443
assert image .blur (2 ) == snapshot_png
441
444
@@ -446,7 +449,7 @@ class TestCrop:
446
449
["image/plane.png" ],
447
450
ids = ["crop" ],
448
451
)
449
- def test_should_return_cropped_image (self , resource_path : str , snapshot_png ) -> None :
452
+ def test_should_return_cropped_image (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
450
453
image = Image .from_png_file (resolve_resource_path (resource_path ))
451
454
assert image .crop (0 , 0 , 100 , 100 ) == snapshot_png
452
455
@@ -461,7 +464,7 @@ class TestSharpen:
461
464
],
462
465
ids = ["negative factor" , "small factor" , "large factor" ],
463
466
)
464
- def test_should_sharpen (self , resource_path : str , factor : float , snapshot_png ) -> None :
467
+ def test_should_sharpen (self , resource_path : str , factor : float , snapshot_png : SnapshotAssertion ) -> None :
465
468
image = Image .from_png_file (resolve_resource_path (resource_path ))
466
469
assert image .sharpen (factor ) == snapshot_png
467
470
@@ -477,7 +480,7 @@ class TestRotate:
477
480
["image/plane.png" ],
478
481
ids = ["rotate-clockwise" ],
479
482
)
480
- def test_should_return_clockwise_rotated_image (self , resource_path : str , snapshot_png ) -> None :
483
+ def test_should_return_clockwise_rotated_image (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
481
484
image = Image .from_png_file (resolve_resource_path (resource_path ))
482
485
assert image .rotate_right () == snapshot_png
483
486
@@ -486,7 +489,9 @@ def test_should_return_clockwise_rotated_image(self, resource_path: str, snapsho
486
489
["image/plane.png" ],
487
490
ids = ["rotate-counter-clockwise" ],
488
491
)
489
- def test_should_return_counter_clockwise_rotated_image (self , resource_path : str , snapshot_png ) -> None :
492
+ def test_should_return_counter_clockwise_rotated_image (
493
+ self , resource_path : str , snapshot_png : SnapshotAssertion
494
+ ) -> None :
490
495
image = Image .from_png_file (resolve_resource_path (resource_path ))
491
496
assert image .rotate_left () == snapshot_png
492
497
@@ -497,6 +502,6 @@ class TestFindEdges:
497
502
["image/plane.png" ],
498
503
ids = ["find_edges" ],
499
504
)
500
- def test_should_return_edges_of_image (self , resource_path : str , snapshot_png ) -> None :
505
+ def test_should_return_edges_of_image (self , resource_path : str , snapshot_png : SnapshotAssertion ) -> None :
501
506
image = Image .from_png_file (resolve_resource_path (resource_path ))
502
507
assert image .find_edges () == snapshot_png
0 commit comments