-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from jamescooke/comments
Ban inline comments from Act blocks
- Loading branch information
Showing
38 changed files
with
1,093 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.PHONY: all | ||
all: good/black/noqa | ||
|
||
good/black/noqa: good/black | ||
mkdir good/black/noqa | ||
cp good/noqa/*.py good/black/noqa/ | ||
|
||
good/black: | ||
mkdir good/black | ||
cp good/*.py good/black/ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf good/black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
|
||
# Example from AAA06 doc: | ||
|
||
|
||
def test() -> None: | ||
shopping = ['apples', 'bananas', 'cabbages'] | ||
|
||
# Reverse shopping list operates in place | ||
shopping.reverse() # act | ||
|
||
assert shopping == ['cabbages', 'bananas', 'apples'] | ||
|
||
|
||
def test_act(): | ||
nothing = None | ||
|
||
with pytest.raises(AttributeError): | ||
# You can't get something from nothing | ||
nothing.get_something() | ||
|
||
|
||
# --- OTHERS --- | ||
|
||
|
||
def test_comment_after_act() -> None: | ||
x = 1 | ||
y = 2 | ||
|
||
result = x + y | ||
# Now check result | ||
|
||
assert result == 3 | ||
|
||
|
||
def test_raises(): | ||
nothing = None | ||
|
||
with pytest.raises(AttributeError): | ||
# You can't get something from nothing | ||
nothing.get_something() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,99 @@ | ||
# Test for various comments before and after test blocks | ||
from typing import List | ||
|
||
# Example from AAA06 doc: | ||
# * inline comment is OK for marking | ||
|
||
def test_comment_before_act(): | ||
x = 1 | ||
y = 2 | ||
|
||
# Sum x and y | ||
result = x + y | ||
def test() -> None: | ||
""" | ||
Reverse shopping list operates in place | ||
""" | ||
shopping = ["apples", "bananas", "cabbages"] | ||
|
||
shopping.reverse() # act | ||
|
||
assert shopping == ["cabbages", "bananas", "apples"] | ||
|
||
|
||
def test_ignore_typing() -> None: | ||
""" | ||
Reverse shopping list operates in place | ||
""" | ||
shopping = ["apples", "bananas", "cabbages"] | ||
|
||
result = shopping.reverse() # type: ignore | ||
|
||
assert result == 2 | ||
assert result is None | ||
assert shopping == ["cabbages", "bananas", "apples"] | ||
|
||
|
||
def test_comment_after_act(): | ||
# Comments are OK in Arrange and Assert. | ||
|
||
|
||
def test_in_arrange(): | ||
x = 3 | ||
# Let's make a 3, 4, 5 triangle | ||
y = 4 | ||
|
||
result = x ** 2 + y ** 2 | ||
|
||
assert result == 25 | ||
|
||
|
||
def test_end_arrange() -> None: | ||
x = 1 | ||
y = 2 | ||
# Now test... | ||
|
||
result = x + y | ||
# Sum x and y | ||
|
||
assert result == 2 | ||
assert result == 3 | ||
|
||
|
||
def test_in_assert(): | ||
result = list() | ||
|
||
assert not result | ||
# A copy of nothing is nothing | ||
assert result.copy() == [] | ||
|
||
def test_comment_before_assert(): | ||
|
||
def test_startassert() -> None: | ||
x = 1 | ||
y = 2 | ||
|
||
result = x + y | ||
|
||
# Always 2 | ||
assert result == 2 | ||
# Always 3 | ||
assert result == 3 | ||
|
||
|
||
# Comments are OK in strings | ||
|
||
|
||
def test_strings() -> None: | ||
special_chars = """ | ||
#!$[]{} | ||
""".strip() | ||
|
||
result = len(special_chars) | ||
|
||
assert result == 7 | ||
|
||
|
||
def test_string_act(): | ||
result = """ | ||
# Not a comment - it's a string | ||
""" | ||
|
||
assert len(result) == 33 | ||
|
||
|
||
# Comment are OK before the test | ||
|
||
|
||
# NOTE: igore this comment | ||
def test_empty() -> None: | ||
result: List[int] = list() | ||
|
||
assert len(result) == 0 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.