---
source: crates/ruff/src/rules/flake8_pytest_style/mod.rs
---
PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts
   |
14 | def test_error():
15 |     assert something and something_else
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
16 |     assert something and something_else and something_third
17 |     assert something and not something_else
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
11 11 | 
12 12 | 
13 13 | def test_error():
14    |-    assert something and something_else
   14 |+    assert something
   15 |+    assert something_else
15 16 |     assert something and something_else and something_third
16 17 |     assert something and not something_else
17 18 |     assert something and (something_else or something_third)

PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts
   |
15 | def test_error():
16 |     assert something and something_else
17 |     assert something and something_else and something_third
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
18 |     assert something and not something_else
19 |     assert something and (something_else or something_third)
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
12 12 | 
13 13 | def test_error():
14 14 |     assert something and something_else
15    |-    assert something and something_else and something_third
   15 |+    assert something and something_else
   16 |+    assert something_third
16 17 |     assert something and not something_else
17 18 |     assert something and (something_else or something_third)
18 19 |     assert not something and something_else

PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts
   |
16 |     assert something and something_else
17 |     assert something and something_else and something_third
18 |     assert something and not something_else
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
19 |     assert something and (something_else or something_third)
20 |     assert not something and something_else
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
13 13 | def test_error():
14 14 |     assert something and something_else
15 15 |     assert something and something_else and something_third
16    |-    assert something and not something_else
   16 |+    assert something
   17 |+    assert not something_else
17 18 |     assert something and (something_else or something_third)
18 19 |     assert not something and something_else
19 20 |     assert not (something or something_else)

PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts
   |
17 |     assert something and something_else and something_third
18 |     assert something and not something_else
19 |     assert something and (something_else or something_third)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
20 |     assert not something and something_else
21 |     assert not (something or something_else)
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
14 14 |     assert something and something_else
15 15 |     assert something and something_else and something_third
16 16 |     assert something and not something_else
17    |-    assert something and (something_else or something_third)
   17 |+    assert something
   18 |+    assert (something_else or something_third)
18 19 |     assert not something and something_else
19 20 |     assert not (something or something_else)
20 21 |     assert not (something or something_else or something_third)

PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts
   |
18 |     assert something and not something_else
19 |     assert something and (something_else or something_third)
20 |     assert not something and something_else
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
21 |     assert not (something or something_else)
22 |     assert not (something or something_else or something_third)
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
15 15 |     assert something and something_else and something_third
16 16 |     assert something and not something_else
17 17 |     assert something and (something_else or something_third)
18    |-    assert not something and something_else
   18 |+    assert not something
   19 |+    assert something_else
19 20 |     assert not (something or something_else)
20 21 |     assert not (something or something_else or something_third)
21 22 |     assert something and something_else == """error

PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts
   |
19 |     assert something and (something_else or something_third)
20 |     assert not something and something_else
21 |     assert not (something or something_else)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
22 |     assert not (something or something_else or something_third)
23 |     assert something and something_else == """error
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
16 16 |     assert something and not something_else
17 17 |     assert something and (something_else or something_third)
18 18 |     assert not something and something_else
19    |-    assert not (something or something_else)
   19 |+    assert not something
   20 |+    assert not something_else
20 21 |     assert not (something or something_else or something_third)
21 22 |     assert something and something_else == """error
22 23 |     message

PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts
   |
20 |     assert not something and something_else
21 |     assert not (something or something_else)
22 |     assert not (something or something_else or something_third)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
23 |     assert something and something_else == """error
24 |     message
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
17 17 |     assert something and (something_else or something_third)
18 18 |     assert not something and something_else
19 19 |     assert not (something or something_else)
20    |-    assert not (something or something_else or something_third)
   20 |+    assert not something or something_else
   21 |+    assert not something_third
21 22 |     assert something and something_else == """error
22 23 |     message
23 24 |     """

PT018.py:21:5: PT018 [*] Assertion should be broken down into multiple parts
   |
21 |       assert not (something or something_else)
22 |       assert not (something or something_else or something_third)
23 |       assert something and something_else == """error
   |  _____^
24 | |     message
25 | |     """
   | |_______^ PT018
26 |   
27 |       # recursive case
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
18 18 |     assert not something and something_else
19 19 |     assert not (something or something_else)
20 20 |     assert not (something or something_else or something_third)
21    |-    assert something and something_else == """error
   21 |+    assert something
   22 |+    assert something_else == """error
22 23 |     message
23 24 |     """
24 25 | 

PT018.py:26:5: PT018 [*] Assertion should be broken down into multiple parts
   |
26 |     # recursive case
27 |     assert not (a or not (b or c))
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
28 |     assert not (a or not (b and c))
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
23 23 |     """
24 24 | 
25 25 |     # recursive case
26    |-    assert not (a or not (b or c))
   26 |+    assert not a
   27 |+    assert (b or c)
27 28 |     assert not (a or not (b and c))
28 29 | 
29 30 |     # detected, but no autofix for messages

PT018.py:27:5: PT018 [*] Assertion should be broken down into multiple parts
   |
27 |     # recursive case
28 |     assert not (a or not (b or c))
29 |     assert not (a or not (b and c))
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
30 | 
31 |     # detected, but no autofix for messages
   |
   = help: Break down assertion into multiple parts

ℹ Suggested fix
24 24 | 
25 25 |     # recursive case
26 26 |     assert not (a or not (b or c))
27    |-    assert not (a or not (b and c))
   27 |+    assert not a
   28 |+    assert (b and c)
28 29 | 
29 30 |     # detected, but no autofix for messages
30 31 |     assert something and something_else, "error message"

PT018.py:30:5: PT018 Assertion should be broken down into multiple parts
   |
30 |     # detected, but no autofix for messages
31 |     assert something and something_else, "error message"
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
32 |     assert not (something or something_else and something_third), "with message"
33 |     # detected, but no autofix for mixed conditions (e.g. `a or b and c`)
   |

PT018.py:31:5: PT018 Assertion should be broken down into multiple parts
   |
31 |     # detected, but no autofix for messages
32 |     assert something and something_else, "error message"
33 |     assert not (something or something_else and something_third), "with message"
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
34 |     # detected, but no autofix for mixed conditions (e.g. `a or b and c`)
35 |     assert not (something or something_else and something_third)
   |

PT018.py:33:5: PT018 Assertion should be broken down into multiple parts
   |
33 |     assert not (something or something_else and something_third), "with message"
34 |     # detected, but no autofix for mixed conditions (e.g. `a or b and c`)
35 |     assert not (something or something_else and something_third)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018
36 |     # detected, but no autofix for parenthesized conditions
37 |     assert (
   |

PT018.py:35:5: PT018 [*] Assertion should be broken down into multiple parts
   |
35 |       assert not (something or something_else and something_third)
36 |       # detected, but no autofix for parenthesized conditions
37 |       assert (
   |  _____^
38 | |         something
39 | |         and something_else
40 | |         == """error
41 | | message
42 | | """
43 | |     )
   | |_____^ PT018
   |
   = help: Break down assertion into multiple parts


