You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of v0.9.0, Flake8-AAA considers that allwith statements wrapping the Act block are part of that Act block. So for a simple test using open() this is the current required layout:
Analysis shows that the with open() statement has been absorbed into the Act block:
$ python -m flake8_aaa test.py
------+------------------------------------------------------------------------
1 DEF|def test():
2 ACT| with open('f.txt') as f:
3 ACT| result = f.read()
4 BL |
5 ASS| assert result == 'Hello World!\n'
------+------------------------------------------------------------------------
0 | ERRORS
======+========================================================================
PASSED!
Doing an open() on a file is an Arrange operation - it's preparing for the test. Therefore it should be part of the Arrange block. That means that the Act block just consists of the result assignment line result = f.read().
Now for the layout - the README states:
each test is broken down into three distinct parts separated by blank lines.
Therefore there must be a blank line before the result assignment. It is inside the with statement block and the test is laid out as:
Current behaviour
As of v0.9.0, Flake8-AAA considers that all
with
statements wrapping the Act block are part of that Act block. So for a simple test usingopen()
this is the current required layout:Analysis shows that the
with open()
statement has been absorbed into the Act block:Doing an
open()
on a file is an Arrange operation - it's preparing for the test. Therefore it should be part of the Arrange block. That means that the Act block just consists of the result assignment lineresult = f.read()
.Now for the layout - the README states:
Therefore there must be a blank line before the result assignment. It is inside the
with
statement block and the test is laid out as:However, using this layout with the current version of Flake8-AAA gives an error - analysis shows:
Expected behaviour
No error is raised from the example above, analysis gives line 2 as an Arrange block:
Checklist
Remove Act block building code that vacuums up parent
with
statements.Add new examples to good files:
with
in Arrange,with
in Assert,with
spanning whole testAdd bad examples for: non-assertive
with
wrapping Act (assignment and raises types).Run
pytest
against new / edited good and bad examples. All examples should be executable tests and passing.Check how black likes to format
with
statements - there may be incompatibility.Update documentation on "Build Act Block" https://flake8-aaa.readthedocs.io/en/stable/discovery.html#build-act-block
Update CHANGELOG
The text was updated successfully, but these errors were encountered: