forked from jamescooke/flake8-aaa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs on Large style Act blocks (jamescooke#219)
- Loading branch information
1 parent
8abe040
commit 29ed661
Showing
9 changed files
with
131 additions
and
36 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
46 changes: 40 additions & 6 deletions
46
docs/error_codes/AAA03-expected-1-blank-line-before-act-block.rst
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,17 +1,51 @@ | ||
AAA03: expected 1 blank line before Act block, found none | ||
--------------------------------------------------------- | ||
========================================================= | ||
|
||
For tests that have an Arrange block, there must be a blank line between the | ||
Arrange and Act blocks, but Flake8-AAA could not find one. | ||
|
||
This blank line creates separation between the arrangement and the action and | ||
makes the Act block easy to spot. | ||
Prerequisites | ||
------------- | ||
|
||
This rule works best with `pycodestyle | ||
<https://pypi.org/project/pycodestyle/>`_'s ``E303`` rule enabled because it | ||
ensures that there are not multiple blank lines between the blocks. | ||
|
||
Resolution | ||
.......... | ||
If test code is formatted with Black, then it's best to set :ref:`"large" Act | ||
block style <large-act-block-style>`. | ||
|
||
Add a blank line before the Act block. | ||
Problematic code | ||
---------------- | ||
|
||
.. code-block:: python | ||
def test_simple(hello_world_path: pathlib.Path) -> None: | ||
with open(hello_world_path) as f: | ||
result = f.read() | ||
assert result == 'Hello World!\n' | ||
Correct code | ||
------------ | ||
|
||
Since the ``open()`` context manager is part of the Arrange block, create space | ||
between it and the ``result =`` Act block. | ||
|
||
.. code-block:: python | ||
def test_simple(hello_world_path: pathlib.Path) -> None: | ||
with open(hello_world_path) as f: | ||
result = f.read() | ||
assert result == 'Hello World!\n' | ||
Alternatively, if you want the context manager to be treated as part of the Act | ||
block, the :ref:`"large" Act block style <large-act-block-style>` as mentioned | ||
above. | ||
|
||
Rationale | ||
--------- | ||
|
||
This blank line creates separation between the test's Arrange and Act blocks | ||
and makes the Act block easy to spot. |
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