Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust rules for comments #148

Closed
jamescooke opened this issue May 9, 2020 · 0 comments · Fixed by #160
Closed

Adjust rules for comments #148

jamescooke opened this issue May 9, 2020 · 0 comments · Fixed by #160
Assignees

Comments

@jamescooke
Copy link
Owner

# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant