# comments are helpful in complicated tests but they can be disruptive to test structure. This is my current thinking:
- Arrange:
# comments allowed throughout.
- Act: No
# comments allowed - if something is important enough to comment in the Act block, then it should go in the docstring of the test itself.
- Arrange:
# comments allowed throughout.
Good examples that need to be edited:
|
def test_act(): |
|
nothing = None |
|
|
|
with pytest.raises(AttributeError): |
|
# You can't get something from nothing |
|
nothing.get_something() |
|
|
|
|
|
def test_assert(): |
|
result = list() |
|
|
|
assert not result |
|
# A copy of nothing is nothing |
|
assert result.copy() == [] |
|
def test_comment_before_act(): |
|
x = 1 |
|
y = 2 |
|
|
|
# Sum x and y |
|
result = x + y |
|
|
|
assert result == 2 |
|
|
|
|
|
def test_comment_after_act(): |
|
x = 1 |
|
y = 2 |
|
|
|
result = x + y |
|
# Sum x and y |
|
|
|
assert result == 2 |
# commentsare helpful in complicated tests but they can be disruptive to test structure. This is my current thinking:# commentsallowed throughout.# commentsallowed - if something is important enough to comment in the Act block, then it should go in the docstring of the test itself.# commentsallowed throughout.Good examples that need to be edited:
flake8-aaa/examples/good/test_comments_aaa05.py
Lines 14 to 27 in de688e5
flake8-aaa/examples/good/test_comments.py
Lines 4 to 21 in de688e5