@@ -13,13 +13,15 @@ class TestFromJpegFile:
13
13
@pytest .mark .parametrize (
14
14
"path" ,
15
15
["image/white_square.jpg" , Path ("image/white_square.jpg" )],
16
+ ids = ["jpg" , "jpg_Path" ],
16
17
)
17
18
def test_should_load_jpeg_file (self , path : str | Path ) -> None :
18
19
Image .from_jpeg_file (resolve_resource_path (path ))
19
20
20
21
@pytest .mark .parametrize (
21
22
"path" ,
22
23
["image/missing_file.jpg" , Path ("image/missing_file.jpg" )],
24
+ ids = ["missing_file_jpg" , "missing_file_jpg_Path" ],
23
25
)
24
26
def test_should_raise_if_file_not_found (self , path : str | Path ) -> None :
25
27
with pytest .raises (FileNotFoundError ):
@@ -30,13 +32,15 @@ class TestFromPngFile:
30
32
@pytest .mark .parametrize (
31
33
"path" ,
32
34
["image/white_square.png" , Path ("image/white_square.png" )],
35
+ ids = ["png" , "png_Path" ],
33
36
)
34
37
def test_should_load_png_file (self , path : str | Path ) -> None :
35
38
Image .from_png_file (resolve_resource_path (path ))
36
39
37
40
@pytest .mark .parametrize (
38
41
"path" ,
39
42
["image/missing_file.png" , Path ("image/missing_file.png" )],
43
+ ids = ["missing_file_png" , "missing_file_png_Path" ],
40
44
)
41
45
def test_should_raise_if_file_not_found (self , path : str | Path ) -> None :
42
46
with pytest .raises (FileNotFoundError ):
@@ -50,6 +54,7 @@ class TestFormat:
50
54
(Image .from_jpeg_file (resolve_resource_path ("image/white_square.jpg" )), ImageFormat .JPEG ),
51
55
(Image .from_png_file (resolve_resource_path ("image/white_square.png" )), ImageFormat .PNG ),
52
56
],
57
+ ids = ["jpg" , "png" ],
53
58
)
54
59
def test_should_return_correct_format (self , image : Image , format_ : ImageFormat ) -> None :
55
60
assert image .format == format_
@@ -78,10 +83,7 @@ def test_should_return_image_properties(self, image: Image, width: int, height:
78
83
79
84
80
85
class TestToJpegFile :
81
- @pytest .mark .parametrize (
82
- "path" ,
83
- ["image/white_square.jpg" ],
84
- )
86
+ @pytest .mark .parametrize ("path" , ["image/white_square.jpg" ], ids = ["jpg_file" ])
85
87
def test_should_save_jpeg_file_by_str (self , path : str ) -> None :
86
88
image = Image .from_jpeg_file (resolve_resource_path (path ))
87
89
@@ -94,10 +96,7 @@ def test_should_save_jpeg_file_by_str(self, path: str) -> None:
94
96
95
97
assert image ._image .tobytes () == image_read_back ._image .tobytes ()
96
98
97
- @pytest .mark .parametrize (
98
- "path" ,
99
- ["image/white_square.jpg" ],
100
- )
99
+ @pytest .mark .parametrize ("path" , ["image/white_square.jpg" ], ids = ["jpg" ])
101
100
def test_should_save_jpeg_file_by_path (self , path : str ) -> None :
102
101
image = Image .from_jpeg_file (resolve_resource_path (path ))
103
102
@@ -112,10 +111,7 @@ def test_should_save_jpeg_file_by_path(self, path: str) -> None:
112
111
113
112
114
113
class TestToPngFile :
115
- @pytest .mark .parametrize (
116
- "path" ,
117
- ["image/white_square.png" ],
118
- )
114
+ @pytest .mark .parametrize ("path" , ["image/white_square.png" ], ids = ["png" ])
119
115
def test_should_save_png_file_by_str (self , path : str ) -> None :
120
116
image = Image .from_png_file (resolve_resource_path (path ))
121
117
@@ -128,10 +124,7 @@ def test_should_save_png_file_by_str(self, path: str) -> None:
128
124
129
125
assert image ._image .tobytes () == image_read_back ._image .tobytes ()
130
126
131
- @pytest .mark .parametrize (
132
- "path" ,
133
- ["image/white_square.png" ],
134
- )
127
+ @pytest .mark .parametrize ("path" , ["image/white_square.png" ], ids = ["png" ])
135
128
def test_should_save_png_file_by_path (self , path : str ) -> None :
136
129
image = Image .from_png_file (resolve_resource_path (path ))
137
130
@@ -149,13 +142,15 @@ class TestReprJpeg:
149
142
@pytest .mark .parametrize (
150
143
"image" ,
151
144
[Image .from_jpeg_file (resolve_resource_path ("image/white_square.jpg" ))],
145
+ ids = ["jpg" ],
152
146
)
153
147
def test_should_return_bytes_if_image_is_jpeg (self , image : Image ) -> None :
154
148
assert isinstance (image ._repr_jpeg_ (), bytes )
155
149
156
150
@pytest .mark .parametrize (
157
151
"image" ,
158
152
[Image .from_png_file (resolve_resource_path ("image/white_square.png" ))],
153
+ ids = ["png" ],
159
154
)
160
155
def test_should_return_none_if_image_is_not_jpeg (self , image : Image ) -> None :
161
156
assert image ._repr_jpeg_ () is None
@@ -165,13 +160,15 @@ class TestReprPng:
165
160
@pytest .mark .parametrize (
166
161
"image" ,
167
162
[Image .from_png_file (resolve_resource_path ("image/white_square.png" ))],
163
+ ids = ["png" ],
168
164
)
169
165
def test_should_return_bytes_if_image_is_png (self , image : Image ) -> None :
170
166
assert isinstance (image ._repr_png_ (), bytes )
171
167
172
168
@pytest .mark .parametrize (
173
169
"image" ,
174
170
[Image .from_jpeg_file (resolve_resource_path ("image/white_square.jpg" ))],
171
+ ids = ["jpg" ],
175
172
)
176
173
def test_should_return_none_if_image_is_not_png (self , image : Image ) -> None :
177
174
assert image ._repr_png_ () is None
@@ -262,7 +259,7 @@ def test_should_be_original(self) -> None:
262
259
263
260
264
261
class TestAdjustContrast :
265
- @pytest .mark .parametrize ("factor" , [0.75 , 5 ])
262
+ @pytest .mark .parametrize ("factor" , [0.75 , 5 ], ids = [ "small factor" , "large factor" ] )
266
263
def test_should_adjust_contrast (self , factor : float ) -> None :
267
264
image = Image .from_png_file (resolve_resource_path ("image/contrast/to_adjust_contrast.png" ))
268
265
image2 = image .adjust_contrast (factor )
@@ -288,7 +285,7 @@ def test_should_raise(self) -> None:
288
285
289
286
290
287
class TestBrightness :
291
- @pytest .mark .parametrize ("factor" , [0.5 , 10 ])
288
+ @pytest .mark .parametrize ("factor" , [0.5 , 10 ], ids = [ "small factor" , "large factor" ] )
292
289
def test_should_adjust_brightness (self , factor : float ) -> None :
293
290
image = Image .from_png_file (resolve_resource_path ("image/brightness/to_brighten.png" ))
294
291
image2 = image .adjust_brightness (factor )
@@ -360,7 +357,7 @@ def test_should_return_cropped_image(self, image: Image, expected: Image) -> Non
360
357
361
358
362
359
class TestSharpen :
363
- @pytest .mark .parametrize ("factor" , [- 1 , 0.5 , 10 ])
360
+ @pytest .mark .parametrize ("factor" , [- 1 , 0.5 , 10 ], ids = [ "negative factor" , "small factor" , "large factor" ] )
364
361
def test_should_sharpen (self , factor : float ) -> None :
365
362
image = Image .from_png_file (resolve_resource_path ("image/sharpen/to_sharpen.png" ))
366
363
image2 = image .sharpen (factor )
0 commit comments