diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index c02e53b8cc5..9dd42123546 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -643,30 +643,25 @@ def test_save_low_quality_baseline_qtables(self): assert max(im2.quantization[0]) <= 255 assert max(im2.quantization[1]) <= 255 - def test_restart_markers(self): + @pytest.mark.parametrize( + "blocks, rows, markers", + ((0, 0, 0), (1, 0, 15), (3, 0, 5), (8, 0, 1), (0, 1, 3), (0, 2, 1)), + ) + def test_restart_markers(self, blocks, rows, markers): im = Image.new("RGB", (32, 32)) # 16 MCUs - cases = ( - (0, 0, 0), - (1, 0, 15), - (3, 0, 5), - (8, 0, 1), - (0, 1, 3), - (0, 2, 1), + out = BytesIO() + im.save( + out, + format="JPEG", + restart_marker_blocks=blocks, + restart_marker_rows=rows, + # force 8x8 pixel MCUs + subsampling=0, ) - for blocks, rows, markers in cases: - out = BytesIO() - im.save( - out, - format="JPEG", - restart_marker_blocks=blocks, - restart_marker_rows=rows, - # force 8x8 pixel MCUs - subsampling=0, - ) - found_markers = sum( - len(out.getvalue().split(bytes([0xFF, 0xD0 + i]))) - 1 for i in range(8) - ) - assert markers == found_markers + markers_found = sum( + len(out.getvalue().split(bytes([0xFF, 0xD0 + i]))) - 1 for i in range(8) + ) + assert markers_found == markers @pytest.mark.skipif(not djpeg_available(), reason="djpeg not available") def test_load_djpeg(self):