Skip to content

Commit 5747267

Browse files
committed
Fix PT018: Assert only one thing
1 parent 5c282d0 commit 5747267

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

Tests/test_file_jpeg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,13 +1019,16 @@ def test_separate_tables(self) -> None:
10191019

10201020
# SOI, EOI
10211021
for marker in b"\xff\xd8", b"\xff\xd9":
1022-
assert marker in data[1] and marker in data[2]
1022+
assert marker in data[1]
1023+
assert marker in data[2]
10231024
# DHT, DQT
10241025
for marker in b"\xff\xc4", b"\xff\xdb":
1025-
assert marker in data[1] and marker not in data[2]
1026+
assert marker in data[1]
1027+
assert marker not in data[2]
10261028
# SOF0, SOS, APP0 (JFIF header)
10271029
for marker in b"\xff\xc0", b"\xff\xda", b"\xff\xe0":
1028-
assert marker not in data[1] and marker in data[2]
1030+
assert marker not in data[1]
1031+
assert marker in data[2]
10291032

10301033
with Image.open(BytesIO(data[0])) as interchange_im:
10311034
with Image.open(BytesIO(data[1] + data[2])) as combined_im:

Tests/test_imagechops.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ def table(
398398
for y in (a, b):
399399
imy = Image.new("1", (1, 1), y)
400400
value = op(imx, imy).getpixel((0, 0))
401-
assert not isinstance(value, tuple) and value is not None
401+
assert not isinstance(value, tuple)
402+
assert value is not None
402403
out.append(value)
403404
return out
404405

Tests/test_imagemorph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def img_to_string(im: Image.Image) -> str:
4646
line = ""
4747
for c in range(im.width):
4848
value = im.getpixel((c, r))
49-
assert not isinstance(value, tuple) and value is not None
49+
assert not isinstance(value, tuple)
50+
assert value is not None
5051
line += chars[value > 0]
5152
result.append(line)
5253
return "\n".join(result)

Tests/test_tiff_ifdrational.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def test_nonetype() -> None:
5454
assert xres.denominator is not None
5555
assert yres._val is not None
5656

57-
assert xres and 1
58-
assert xres and yres
57+
assert xres
58+
assert yres
5959

6060

6161
@pytest.mark.parametrize(

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ lint.ignore = [
127127
"PT012", # pytest-raises-with-multiple-statements
128128
"PT016", # pytest-fail-without-message
129129
"PT017", # pytest-assert-in-except
130-
"PT018", # pytest-composite-assertion
131130
"PYI026", # flake8-pyi: typing.TypeAlias added in Python 3.10
132131
"PYI034", # flake8-pyi: typing.Self added in Python 3.11
133132
]

0 commit comments

Comments
 (0)