Flake8-AAA
A linter for Python tests.
Flake8-AAA enforces simple formatting of your test suite making it more consistent and easier to grok, especially across teams.
Installation and usage
Flake8-AAA is a Flake8 plugin.
Install flake8-aaa with pip, which will also install flake8:
$ pip install flake8-aaa
Invoke Flake8 on your test suite, in this case in the tests directory:
$ flake8 tests
Errors returned by Flake8-AAA have the AAA code, for example:
tests/block/test_init.py:14:1: AAA02 multiple Act blocks found in test
Arrange Act Assert
Tests are linted against the Arrange Act Assert pattern.
TL;DR following the AAA pattern means tests are laid out like this:
def test():
"""
__docstring__
"""
<ARRANGE block> # set up of the system under test (SUT)
<ACT block> # perform a single action on the SUT
<ASSERT block> # check that the SUT changed as expected
For example:
def test(tmpdir):
"""
Checker is able to parse provided file at load time
"""
target_file = tmpdir.join('test.py')
target_file.write('assert 1 + 2 == 3\n')
tree = ast.parse(target_file.read())
checker = Checker(tree, ['assert 1 + 2 == 3\n'], target_file.strpath)
result = checker.load()
assert result is None
assert len(checker.tree.body) == 1
assert type(checker.tree.body[0]) == ast.Assert
assert len(checker.ast_tokens.tokens) == 8
More examples are in our test suite’s “good” files.
Compatibility
Pytest and unittest supported.
Compatible with Black and yapf formatted code.
Current release works with the latest versions of Python 3 (3.5, 3.6, 3.7 and 3.8). Older releases have support for older Pythons.
See the Compatibility list for more info.
Resources
Metadata
Release files for flake8-aaa 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8-aaa-0.7.1.tar.gz | 13.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_aaa-0.7.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.3 kB
Release files / flake8-aaa-0.7.1.tar.gz
| Download URL | flake8-aaa-0.7.1.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e30b1807353faec170363be3e4a6abd3e488cfe608e806eb0c9c03aef102f99f
|
|
BLAKE2b-256 checksum How to use checksums |
74ec4826333a428425d67c0c40a20998019c751ed864dbdb224f01106a96bfc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
|
Release files / flake8_aaa-0.7.1-py3-none-any.whl
| Download URL | flake8_aaa-0.7.1-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e747bdddf6689755ce8bc6d87a0819448029f6ddf806bab686429d2a8c900693
|
|
BLAKE2b-256 checksum How to use checksums |
aa41d91ce9850dbb3f7130d17a9c4acc2113fdce2b602d95937a6a9f040d9b72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
|