It doesn't work
pomponchik opened this issue · 1 comments
pomponchik commented
I wrote this test (only this in a whole file test_conftest.py
):
def test_some_text():
some = 'some'
text = 'text'
some_text = f'{some}_{text}'
assert some_text == 'some_text'
And i had this:
./tests/test_conftest.py:1:1: AAA01 no Act block found in test
Flake8's version signature:
5.0.4 (flake8-aaa: 0.12.2, flake8-bugbear: 22.10.27, flake8-builtins: 2.0.1, flake8-cognitive-complexity: 0.1.0,
flake8-comprehensions: 3.10.1, flake8-docstrings: 1.6.0, flake8-eradicate: 1.4.0, flake8-expression-complexity: 0.0.1,
flake8-functions: 0.0.7, flake8-import-order: 0.18.1, flake8-pep3101: 2.0.0, flake8-print: 5.0.0, flake8-pytest-style:
1.6.0, flake8-quotes: 3.3.1, mccabe: 0.7.0, pep8-naming: 0.13.2, pycodestyle: 2.9.1, pyflakes: 2.5.0) CPython 3.10.7 on
Darwin
- Python version (output of
python --version
): Python 3.10.7 - Platform: Mac OSX
jamescooke commented
Thanks for trying out Flake8-AAA.
You're receiving error AAA01
successfully - which is great news.
The reason you're getting this error is that Flake8-AAA doesn't know where your Act block is.
Solutions
Problematic code
def test_some_text():
some = 'some'
text = 'text'
some_text = f'{some}_{some}'
assert some_text == 'some_text'
Correct code 1
One option is to use result =
.
def test_some_text():
some = 'some'
text = 'text'
result = f'{some}_{some}'
assert result == 'some_text'
Correct code 2
A second option is to mark your Act block with the # act
hint.
def test_some_text():
some = 'some'
text = 'text'
some_text = f'{some}_{some}' # act
assert some_text == 'some_text'
Further info
- Docs for
AAA01
are here: https://flake8-aaa.readthedocs.io/en/stable/rules.html#aaa01-no-act-block-found-in-test - I'm working through expanding the docs so that each error can have its own page - see #149. Thanks for providing this example for
AAA01
- I'll add it to that page when I build it out 👍🏻
I'll close this issue now.