File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -288,12 +288,13 @@ def test_non_integer_token(tmp_path: Path) -> None:
288
288
pass
289
289
290
290
291
- def test_header_token_too_long (tmp_path : Path ) -> None :
291
+ @pytest .mark .parametrize ("data" , (b"P3\x0c AAAAAAAAAA\xee " , b"P6\n 01234567890" ))
292
+ def test_header_token_too_long (tmp_path : Path , data : bytes ) -> None :
292
293
path = tmp_path / "temp.ppm"
293
294
with open (path , "wb" ) as f :
294
- f .write (b"P6 \n 01234567890" )
295
+ f .write (data )
295
296
296
- with pytest .raises (ValueError , match = "Token too long in file header: 01234567890 " ):
297
+ with pytest .raises (ValueError , match = "Token too long in file header: " ):
297
298
with Image .open (path ):
298
299
pass
299
300
Original file line number Diff line number Diff line change @@ -94,8 +94,8 @@ def _read_token(self) -> bytes:
94
94
msg = "Reached EOF while reading header"
95
95
raise ValueError (msg )
96
96
elif len (token ) > 10 :
97
- msg = f "Token too long in file header: { token . decode () } "
98
- raise ValueError (msg )
97
+ msg_too_long = b "Token too long in file header: %s" % token
98
+ raise ValueError (msg_too_long )
99
99
return token
100
100
101
101
def _open (self ) -> None :
You can’t perform that action at this time.
0 commit comments