Usage
Install by running the command:
pip install pytest-flake8
After installing it, when you run tests with the option:
pytest --flake8
every file ending in .py will be discovered and checked with flake8.
Configuring FLAKE8 options per project and file
Maximum line length can be configured for the whole project by adding a flake8-max-line-length option to your setup.cfg or tox.ini file like this:
# content of setup.cfg [pytest] flake8-max-line-length = 99
Note that the default will be what naturally comes with flake8 (which it turn gets its default from pycodestyle).
You may configure flake8-checking options for your project by adding an flake8-ignore entry to your setup.cfg or tox.ini file like this:
# content of setup.cfg [pytest] flake8-ignore = E201 E231
This would globally prevent complaints about two whitespace issues. Rerunning with the above example will now look better:
$ pytest -q --flake8 collecting ... collected 1 items . 1 passed in 0.01 seconds
If you have some files where you want to specifically ignore some errors or warnings you can start a flake8-ignore line with a glob-pattern and a space-separated list of codes:
# content of setup.cfg
[pytest]
flake8-ignore =
*.py E201
doc/conf.py ALL
So if you have a conf.py like this:
# content of doc/conf.py func ( [1,2,3]) #this line lots PEP8 errors :)
then running again with the previous example will show a single failure and it will ignore doc/conf.py alltogether:
$ pytest --flake8 -v # verbose shows what is ignored ======================================= test session starts ======================================== platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.7.0 -- /Users/tholo/Source/pytest/bin/python cachedir: /Users/tholo/Source/pytest/src/verify/.cache rootdir: /Users/tholo/Source/angular/src/verify, inifile: setup.cfg plugins: flake8, cache collected 1 items myfile.py PASSED ========================================= 1 passed in 0.00 seconds =========================================
Note that doc/conf.py was not considered or imported.
Notes
The repository of this plugin is at https://github.com/tholo/pytest-flake8
For more info on pytest see http://pytest.org
The code is partially based on Ronny Pfannschmidt’s pytest-codecheckers plugin.
Metadata
Release files for pytest-flake8 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest-flake8-1.0.5.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_flake8-1.0.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 14.5 kB
Release files / pytest-flake8-1.0.5.tar.gz
| Download URL | pytest-flake8-1.0.5.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d85efaafbdb9580791cfa8671799dd40d482fc30bd4476c1ca5efd661e751333
|
|
BLAKE2b-256 checksum How to use checksums |
e2d3d1bd06dfca649a3ae2e8fc35a8042b25e17da77e15cbcb87a0d39f1f69df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8
|
Release files / pytest_flake8-1.0.5-py2.py3-none-any.whl
| Download URL | pytest_flake8-1.0.5-py2.py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6e26d94ad41184d9a5113a90179b303efddb53eda505f827418ca78f5b39403a
|
|
BLAKE2b-256 checksum How to use checksums |
07ba9ef175ef67414f7da2e0d33f3be65167ca7874f86b42cded96977497292f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8
|