Skip to main content

pytest plugin to check FLAKE8 requirements

Project description

Usage

Install by running the command:

pip install pytest-flake8

After installing it, when you run tests with the option:

py.test --flake8

every file ending in .py will be discovered and checked with flake8. Note that if optional flake8 plugins are installed, those will also be used.

Configuring FLAKE8 options per project and file

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:

$ py.test -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:

$ py.test --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 py.test 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-0.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

pytest_flake8-0.1-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: pytest-flake8-0.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytest-flake8-0.1.tar.gz
Algorithm Hash digest
SHA256 6b30619538937f274a373ace5fe2895def15066f0d3bad5784458ae0bce61a60
MD5 d0529feaba4368c4a2ba15507ab58c55
BLAKE2b-256 25ad5af4922e569a7ddb40f08c9531be0cdbb489b01b4bf8cc270cbd3c7c47ac

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pytest_flake8-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d2ecd5343ae56b4ac27ffa09d88111cc97dd7fdbc881231dfcdbc852f9ea5121
MD5 844dfc5d8d624824dfc310b4ccd8f681
BLAKE2b-256 cd164ce5c9e295578444a1562cb49ade4976a00afa312054f560f163064fb7ad

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