Skip to content

Commit e3990f6

Browse files
authored
Merge pull request #6900 from Yay295/parametrize_jpeg_leaks_test
Test both lists and tuples as qtables arguments
2 parents 6c800dd + e3dd4de commit e3990f6

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

Tests/check_jpeg_leaks.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,43 +75,42 @@
7575
"""
7676

7777

78-
def test_qtables_leak():
78+
standard_l_qtable = (
79+
# fmt: off
80+
16, 11, 10, 16, 24, 40, 51, 61,
81+
12, 12, 14, 19, 26, 58, 60, 55,
82+
14, 13, 16, 24, 40, 57, 69, 56,
83+
14, 17, 22, 29, 51, 87, 80, 62,
84+
18, 22, 37, 56, 68, 109, 103, 77,
85+
24, 35, 55, 64, 81, 104, 113, 92,
86+
49, 64, 78, 87, 103, 121, 120, 101,
87+
72, 92, 95, 98, 112, 100, 103, 99,
88+
# fmt: on
89+
)
90+
91+
standard_chrominance_qtable = (
92+
# fmt: off
93+
17, 18, 24, 47, 99, 99, 99, 99,
94+
18, 21, 26, 66, 99, 99, 99, 99,
95+
24, 26, 56, 99, 99, 99, 99, 99,
96+
47, 66, 99, 99, 99, 99, 99, 99,
97+
99, 99, 99, 99, 99, 99, 99, 99,
98+
99, 99, 99, 99, 99, 99, 99, 99,
99+
99, 99, 99, 99, 99, 99, 99, 99,
100+
99, 99, 99, 99, 99, 99, 99, 99,
101+
# fmt: on
102+
)
103+
104+
105+
@pytest.mark.parametrize(
106+
"qtables",
107+
(
108+
(standard_l_qtable, standard_chrominance_qtable),
109+
[standard_l_qtable, standard_chrominance_qtable],
110+
),
111+
)
112+
def test_qtables_leak(qtables):
79113
im = hopper("RGB")
80-
81-
standard_l_qtable = [
82-
int(s)
83-
for s in """
84-
16 11 10 16 24 40 51 61
85-
12 12 14 19 26 58 60 55
86-
14 13 16 24 40 57 69 56
87-
14 17 22 29 51 87 80 62
88-
18 22 37 56 68 109 103 77
89-
24 35 55 64 81 104 113 92
90-
49 64 78 87 103 121 120 101
91-
72 92 95 98 112 100 103 99
92-
""".split(
93-
None
94-
)
95-
]
96-
97-
standard_chrominance_qtable = [
98-
int(s)
99-
for s in """
100-
17 18 24 47 99 99 99 99
101-
18 21 26 66 99 99 99 99
102-
24 26 56 99 99 99 99 99
103-
47 66 99 99 99 99 99 99
104-
99 99 99 99 99 99 99 99
105-
99 99 99 99 99 99 99 99
106-
99 99 99 99 99 99 99 99
107-
99 99 99 99 99 99 99 99
108-
""".split(
109-
None
110-
)
111-
]
112-
113-
qtables = [standard_l_qtable, standard_chrominance_qtable]
114-
115114
for _ in range(iterations):
116115
test_output = BytesIO()
117116
im.save(test_output, "JPEG", qtables=qtables)

0 commit comments

Comments
 (0)