jamescooke/flake8-aaa

Adjust rules for comments

jamescooke opened this issue · 0 comments

# 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