Skip to main content

pytest plugin to check FLAKE8 requirements

Project description

https://img.shields.io/pypi/v/pytest-flake8.svg https://img.shields.io/pypi/pyversions/pytest-flake8.svg https://img.shields.io/pypi/implementation/pytest-flake8.svg https://img.shields.io/pypi/status/pytest-flake8.svg https://travis-ci.org/tholo/pytest-flake8.svg?branch=master https://img.shields.io/github/issues/tholo/pytest-flake8.svg https://img.shields.io/github/issues-pr/tholo/pytest-flake8.svg

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-flake8-1.0.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

pytest_flake8-1.0.2-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-flake8-1.0.2.tar.gz.

File metadata

File hashes

Hashes for pytest-flake8-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c740ad6aa19e3958947d2118f70bed218caf1d2097039fb7318573a2a72f89a1
MD5 21215a25170e8772b485049fd9b818e9
BLAKE2b-256 05f469215f7d4b5db7acc7280567ad11752dea85415cbf27110d065f1ee3c9f8

See more details on using hashes here.

Provenance

File details

Details for the file pytest_flake8-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_flake8-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4f30f5be3efb89755f38f11bdb2a5e22d19a6f5faa73428f703a3292a9572cd3
MD5 9fa51dbce1efef8f6ea90841b89c3b1b
BLAKE2b-256 a5a01bb6067862f27d5211a9139af4482424641ccd7c18b3f1ef9a8aa92ffc9f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page