Skip to content

Commit

Permalink
Parametrized test
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 27, 2023
1 parent 9e6157d commit b3437d6
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b3437d6

Please sign in to comment.