flake8-pytest-style
Description
A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
Currently the following errors are reported:
| Code | Description |
|---|---|
| PT001 | use @pytest.fixture() over @pytest.fixture (configurable by pytest-fixture-no-parentheses) |
| PT002 | configuration for fixture '{name}' specified via positional args, use kwargs |
| PT003 | scope='function' is implied in @pytest.fixture() |
| PT004 | fixture '{name}' does not return anything, add leading underscore |
| PT005 | fixture '{name}' returns a value, remove leading underscore |
| PT006 | wrong name(s) type in @pytest.mark.parametrize, expected {expected_type} (configurable by pytest-parametrize-names-type) |
| PT007 | wrong values type in @pytest.mark.parametrize, expected {expected_type} (configurable by pytest-parametrize-values-type and pytest-parametrize-values-row-type) |
| PT008 | use return_value= instead of patching with lambda |
| PT009 | use a regular assert instead of unittest-style '{assertion}' |
| PT010 | set the expected exception in pytest.raises() |
| PT011 | set the match parameter in pytest.raises({exception}) (configurable by pytest-raises-require-match-for) |
| PT012 | pytest.raises() block should contain a single simple statement |
| PT013 | found incorrect import of pytest, use simple 'import pytest' instead |
| PT014 | found duplicate test cases {indexes} in @pytest.mark.parametrize |
| PT015 | assertion always fails, replace with pytest.fail() |
| PT016 | no message passed to pytest.fail() |
| PT017 | found assertion on exception {name} in except block, use pytest.raises() instead |
| PT018 | assertion should be broken down into multiple parts |
| PT019 | fixture {name} without value is injected as parameter, use @pytest.mark.usefixtures instead |
| PT020 | @pytest.yield_fixture is deprecated, use @pytest.fixture |
| PT021 | use yield instead of request.addfinalizer |
Installation
pip install flake8-pytest-style
Configuration
The plugin has the following configuration options:
pytest-fixture-no-parentheses— see PT001pytest-parametrize-names-type— see PT006pytest-parametrize-values-type— see PT007pytest-parametrize-values-row-type— see PT007pytest-raises-require-match-for— see PT011
For developers
Install deps and setup pre-commit hook
make init
Run linters, autoformat, tests etc.
make format lint test
Bump new version
make bump_major
make bump_minor
make bump_patch
License
MIT
Change Log
Unreleased
...
1.2.3 - 2020-08-06
- update
flake8-plugin-utilsdependency to fix encoding problems on Windows
1.2.2 - 2020-07-23
1.2.1 - 2020-06-15
- fix PT021 for factory fixtures (#46)
1.2.0 - 2020-06-12
- support scoped
mockerfixtures frompytest-mockfor PT008 - check for positional-only lambda arguments in PT008
- add PT020 (checks for
pytest.yield_fixture) - add PT021 (checks for
request.addfinalizer) - add documentation pages for all rules
1.1.1 - 2020-04-17
- fix PT011 not reporting
match=''as a violation
1.1.0 - 2020-04-14
- add PT015 (checks for
assert False) - add PT016 (checks for
pytest.fail()without message) - add PT017 (checks for assertions on exceptions in
exceptblocks) - add PT018 (checks for composite assertions)
- add PT019 (checks for fixtures without value injected as parameters)
1.0.0 - 2020-03-26
- add PT014 (checks for duplicate test cases in
@pytest.mark.parametrize)
0.6.0 - 2020-03-21
- add configuration option
pytest-parametrize-names-typefor PT006 - add configuration options
pytest-parametrize-values-typeandpytest-parametrize-values-row-typefor PT007
0.5.0 - 2020-03-09
- add configuration option
pytest-fixture-no-parenthesesfor PT001 - add PT013 (checks for
from-imports frompytest)
0.4.0 - 2020-03-09
- add PT012 (checks for multiple statements in
with pytest.raises())
0.3.1 - 2020-03-09
- fix default value of
pytest-raises-require-match-forconfig option
0.3.0 - 2020-03-09
0.2.0 - 2020-03-01
- add PT009 (ported from flake8-pytest)
0.1.3 - 2019-05-24
- add
yieldfixtures support - fix changelog entry for 0.1.2
0.1.2 - 2019-05-23
- fix parametrize checkers not working in decorators
0.1.1 - 2019-05-23
- update PyPI description
0.1.0 - 2019-05-23
- initial
Release files for flake8-pytest-style 1.2.3
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-pytest-style-1.2.3.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_pytest_style-1.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.4 kB
Release files / flake8-pytest-style-1.2.3.tar.gz
| Download URL | flake8-pytest-style-1.2.3.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48e5ed79ab33846112331bbf51353c568d8a5f515de49c6cd9dfe5fecdcaa6f3
|
|
BLAKE2b-256 checksum How to use checksums |
9efa51c864d83abfdad20824689490281be3f2bb75ff83bd36e8ec12cca4f388
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.0 Linux/4.15.0-1077-gcp
|
Release files / flake8_pytest_style-1.2.3-py3-none-any.whl
| Download URL | flake8_pytest_style-1.2.3-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa6e8706b814b1eedf8f7aa62e26bfc03d0e5178a25d828218165be6c8e52570
|
|
BLAKE2b-256 checksum How to use checksums |
8247f808b6309d95ca43ebf8d5b539e0a6bb852e082d7461c5899dd31957ef96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.0 Linux/4.15.0-1077-gcp
|