A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
Project description
flake8-pytest-style
Description
A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
Currently the following errors are reported:
-
PT001 use @pytest.fixture() over @pytest.fixture -
PT002 configuration for fixture '{name}' specified via positional args, use kwargs
e.g.@pytest.fixture(scope='module')is OK, and@pytest.fixture('module')is an error -
PT003 scope='function' is implied in @pytest.fixture()
e.g.@pytest.fixture(scope='function')should be replaced with@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}
e.g.@pytest.mark.parametrize(('name1', 'name2'), ...)is ok, and@pytest.mark.parametrize('name1,name2', ...)is an error -
PT007 wrong values type in @pytest.mark.parametrize, expected {expected_type} -
PT008 use return_value= instead of patching with lambda
e.g.mocker.patch('target', return_value=7)is OK, andmocker.patch('target', lambda *args: 7)is an error -
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})
e.g.pytest.raises(ValueError, match='exception text')is OK, andpytest.raises(ValueError)is an error.
The exception list is controlled by the configuration optionpytest-raises-require-match-for.
Installation
pip install flake8-pytest-style
Configuration
The plugin has the following configuration options:
pytest-raises-require-match-for
Comma-separated list of exception names that require amatch=parameter in apytest.raises()call, as checked byPT011. By default the list contains the following exceptions:BaseException,ExceptionValueErrorOSError,IOError,EnvironmentError,socket.error
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
...
0.3.0 - 2020-03-09
- add
PT010andPT011(checks forpytest.raisesparameters)
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flake8-pytest-style-0.3.0.tar.gz.
File metadata
- Download URL: flake8-pytest-style-0.3.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.0 Linux/4.15.0-1028-gcp
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94e0b7489320f149deff5d4ee7a852f98819575070e4c4e029c4ddecf3f9c87a
|
|
| MD5 |
50c0a90d5145533ddccf2aa41848f4bd
|
|
| BLAKE2b-256 |
422030f48d84a77d482617b9e6f4b572e2757402b837f640f7fceab792d4260e
|
File details
Details for the file flake8_pytest_style-0.3.0-py3-none-any.whl.
File metadata
- Download URL: flake8_pytest_style-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.0 Linux/4.15.0-1028-gcp
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe77eb875102a3e7c844ea952f2cf7d6e7df4474bff685126e2bf5351bf48f02
|
|
| MD5 |
9d5999e4adee283381ef7e21e241b2e4
|
|
| BLAKE2b-256 |
e8193e099e00c6785e898eef81b1e5042fb880e53a9bb225d86511c663b0a936
|