Skip to main content

pytest plugin to check source code against PEP8 requirements

Project description

py.test plugin for checking PEP8 source code compliance using the pep8 module.

Usage

install via:

easy_install pytest-pep8 # or
pip install pytest-pep8

and then type:

py.test --pep8

to activate source code checking. Every file ending in .py will be discovered and checked, starting from the command line arguments. For example, if you have a file like this:

# content of myfile.py

somefunc( 123,456)

you can run it with:

$ py.test --pep8
=========================== test session starts ============================
platform linux2 -- Python 2.6.5 -- pytest-2.0.1.dev1
pep8 ignore opts: E202 E221 E222 E241 E301 E302 E401 E501 E701 W293 W391 W601 W602
collecting ... collected 1 items

myfile.py F

================================= FAILURES =================================
________________________________ PEP8-check ________________________________
/tmp/doc-exec-12/myfile.py:2:10: E201 whitespace after '('
somefunc( 123,456)
         ^
/tmp/doc-exec-12/myfile.py:2:14: E231 missing whitespace after ','
somefunc( 123,456)
             ^

========================= 1 failed in 0.01 seconds =========================

Note that in the testing header you see the current list of default “ignores”. For the meaning of these error and warning codes, see the error output when running against your files or checkout pep8.py.

Configuring PEP8 options per-project

Lastly, you may configure PEP8-checking options for your project by adding an pep8options entry to your pytest.ini or setup.cfg file like this:

[pytest]
pep8options = +W293 -E200

Running PEP8 checks and no other tests

You can also restrict your test run to only perform “pep8” tests and not any other tests by typing:

py.test --pep8 -k pep8

This will only run tests that are marked with the “pep8” keyword which is added for the pep8 test items added by this plugin.

Notes

The repository of this plugin is at http://bitbucket.org/hpk42/pytest-pep8

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-pep8-0.6.zip (6.9 kB view details)

Uploaded Source

File details

Details for the file pytest-pep8-0.6.zip.

File metadata

  • Download URL: pytest-pep8-0.6.zip
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytest-pep8-0.6.zip
Algorithm Hash digest
SHA256 9c7a918025a9426bf69dc4e26001f31de82d8bad5aaa32d00ad9475662ca2d44
MD5 6a61c132a1e32f107c89e9cbf12a5b3b
BLAKE2b-256 f56bf59d33c2a389d963f6392f0c64d813d9f9c7fa5c5f768404949b8c81dc66

See more details on using hashes here.

Supported by

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