Skip to main content

pytest plugin to check FLAKE8 requirements

Project description

py.test plugin for efficiently checking PEP8 compliance


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

.. note::

If optional flake8 plugins are installed, those will
be used automatically. No provisions have been made for
configuring these via py.test.

.. warning::

Running flake8 tests on your project is likely to cause a number
of issues. The plugin allows one to configure on a per-project and
per-file basis which errors or warnings to ignore, see

.. _flake8-ignore:

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
flake8-max-line-length = 99

Note that the default will be what naturally comes with flake8_
(which it turn gets its default from pep8_).

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
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
flake8-ignore =
*.py E201
doc/ ALL

So if you have a like this::

# content of doc/

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/ 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 PASSED

========================================= 1 passed in 0.00 seconds =========================================

Note that doc/ was not considered or imported.


The repository of this plugin is at

For more info on py.test see

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.

Filename, size & hash SHA256 hash help File type Python version Upload date
pytest_flake8-0.2-py2.py3-none-any.whl (14.9 kB) Copy SHA256 hash SHA256 Wheel py2.py3
pytest-flake8-0.2.tar.gz (6.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page