pytest-pep8-1.0.6/0000775000175000017500000000000012327120613013305 5ustar hpkhpk00000000000000pytest-pep8-1.0.6/LICENSE0000664000175000017500000000204512327120613014313 0ustar hpkhpk00000000000000 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pytest-pep8-1.0.6/setup.py0000664000175000017500000000113212327120613015014 0ustar hpkhpk00000000000000from setuptools import setup if __name__ == "__main__": setup( name='pytest-pep8', description='pytest plugin to check PEP8 requirements', long_description=open("README.txt").read(), license="MIT license", version='1.0.6', author='Holger Krekel and Ronny Pfannschmidt', author_email='holger.krekel@gmail.com', url='http://bitbucket.org/hpk42/pytest-pep8/', py_modules=['pytest_pep8'], entry_points={'pytest11': ['pep8 = pytest_pep8']}, install_requires=['pytest-cache', 'pytest>=2.4.2', 'pep8>=1.3', ], ) pytest-pep8-1.0.6/test_pep8.py0000664000175000017500000000745012327120613015600 0ustar hpkhpk00000000000000# coding=utf8 import pytest import py pytest_plugins = "pytester", def test_version(): import pytest_pep8 assert pytest_pep8.__version__ class TestIgnores: def pytest_funcarg__example(self, request): testdir = request.getfuncargvalue("testdir") p = testdir.makepyfile("") p.write("class AClass:\n pass\n \n\n# too many spaces") return p def test_ignores(self, tmpdir): from pytest_pep8 import Ignorer ignores = ["E203", "b/?.py E204 W205", "z.py ALL", "*.py E300"] ign = Ignorer(ignores) assert ign(tmpdir.join("a/b/x.py")) == "E203 E204 W205 E300".split() assert ign(tmpdir.join("a/y.py")) == "E203 E300".split() assert ign(tmpdir.join("a/z.py")) is None def test_ignores_all(self, testdir): from pytest_pep8 import Ignorer testdir.makeini(""" [pytest] pep8ignore = E203 *.py E300 tests/*.py ALL E203 # something """) testdir.tmpdir.ensure("xy.py") testdir.tmpdir.ensure("tests/hello.py") result = testdir.runpytest("--pep8", "-s") assert result.ret == 0 result.stdout.fnmatch_lines([ "*collected 1*", "*xy.py .*", "*1 passed*", ]) def test_w293w292(self, testdir, example): result = testdir.runpytest("--pep8", ) result.stdout.fnmatch_lines([ # "*plugins*pep8*", "*W293*", "*W292*", ]) assert result.ret != 0 def test_mtime_caching(self, testdir, example): testdir.tmpdir.ensure("hello.py") result = testdir.runpytest("--pep8", ) result.stdout.fnmatch_lines([ # "*plugins*pep8*", "*W293*", "*W292*", "*1 failed*1 passed*", ]) assert result.ret != 0 result = testdir.runpytest("--pep8", ) result.stdout.fnmatch_lines([ "*W293*", "*W292*", "*1 failed*1 skipped*", ]) testdir.makeini(""" [pytest] pep8ignore = *.py W293 W292 """) result = testdir.runpytest("--pep8", ) result.stdout.fnmatch_lines([ "*2 passed*", ]) def test_ok_verbose(testdir): p = testdir.makepyfile(""" class AClass: pass """) p = p.write(p.read() + "\n") result = testdir.runpytest("--pep8", "--verbose") result.stdout.fnmatch_lines([ "*test_ok_verbose*PEP8-check*", ]) assert result.ret == 0 def test_keyword_match(testdir): testdir.makepyfile(""" def test_hello(): a=[ 1,123] # """) result = testdir.runpytest("--pep8", "-mpep8") result.stdout.fnmatch_lines([ "*E201*", "*1 failed*", ]) assert 'passed' not in result.stdout.str() def test_maxlinelength(testdir): testdir.makeini(""" [pytest] pep8maxlinelength = 50 """) testdir.makepyfile(""" # this line is longer than the configured max. line length """) result = testdir.runpytest("--pep8", "-mpep8") result.stdout.fnmatch_lines([ "*E501*", "*1 failed*", ]) assert 'passed' not in result.stdout.str() @pytest.mark.xfail("sys.platform == 'win32'") def test_unicode_error(testdir): x = testdir.tmpdir.join("x.py") import codecs f = codecs.open(str(x), "w", encoding="utf8") f.write(py.builtin._totext(""" # coding=utf8 accent_map = { u'\\xc0': 'a', # À -> a non-ascii comment crashes it } """, "utf8")) f.close() result = testdir.runpytest("--pep8", x, "-s") result.stdout.fnmatch_lines("*non-ascii comment*") def test_strict(testdir): testdir.makepyfile("") result = testdir.runpytest("--strict", "--pep8") assert result.ret == 0 pytest-pep8-1.0.6/pytest_pep8.py0000664000175000017500000001004212327120613016140 0ustar hpkhpk00000000000000import re import py import pytest import pep8 import os __version__ = '1.0.6' HISTKEY = "pep8/mtimes" def pytest_addoption(parser): group = parser.getgroup("general") group.addoption('--pep8', action='store_true', help="perform some pep8 sanity checks on .py files") parser.addini("pep8ignore", type="linelist", help="each line specifies a glob pattern and whitespace " "separated PEP8 errors or warnings which will be ignored, " "example: *.py W293") parser.addini("pep8maxlinelength", help="max. line length (default: %d)" % pep8.MAX_LINE_LENGTH) def pytest_sessionstart(session): config = session.config if config.option.pep8: config._pep8ignore = Ignorer(config.getini("pep8ignore")) config._pep8mtimes = config.cache.get(HISTKEY, {}) config._max_line_length = int(config.getini("pep8maxlinelength") or pep8.MAX_LINE_LENGTH) def pytest_collect_file(path, parent): config = parent.config if config.option.pep8 and path.ext == '.py': pep8ignore = config._pep8ignore(path) if pep8ignore is not None: return Pep8Item(path, parent, pep8ignore, config._max_line_length) def pytest_sessionfinish(session): config = session.config if hasattr(config, "_pep8mtimes"): config.cache.set(HISTKEY, config._pep8mtimes) class Pep8Error(Exception): """ indicates an error during pep8 checks. """ class Pep8Item(pytest.Item, pytest.File): def __init__(self, path, parent, pep8ignore, max_line_length): super(Pep8Item, self).__init__(path, parent) self.add_marker("pep8") self.pep8ignore = pep8ignore self.max_line_length = max_line_length def setup(self): pep8mtimes = self.config._pep8mtimes self._pep8mtime = self.fspath.mtime() old = pep8mtimes.get(str(self.fspath), (0, [])) if old == (self._pep8mtime, self.pep8ignore): pytest.skip("file(s) previously passed PEP8 checks") def runtest(self): call = py.io.StdCapture.call found_errors, out, err = call(check_file, self.fspath, self.pep8ignore, self.max_line_length) if found_errors: raise Pep8Error(out, err) # update mtime only if test passed # otherwise failures would not be re-run next time self.config._pep8mtimes[str(self.fspath)] = (self._pep8mtime, self.pep8ignore) def repr_failure(self, excinfo): if excinfo.errisinstance(Pep8Error): return excinfo.value.args[0] return super(Pep8Item, self).repr_failure(excinfo) def reportinfo(self): if self.pep8ignore: ignores = "(ignoring %s)" % " ".join(self.pep8ignore) else: ignores = "" return (self.fspath, -1, "PEP8-check%s" % ignores) class Ignorer: def __init__(self, ignorelines, coderex=re.compile("[EW]\d\d\d")): self.ignores = ignores = [] for line in ignorelines: i = line.find("#") if i != -1: line = line[:i] try: glob, ign = line.split(None, 1) except ValueError: glob, ign = None, line if glob and coderex.match(glob): glob, ign = None, line ign = ign.split() if "ALL" in ign: ign = None if glob and "/" != os.sep and "/" in glob: glob = glob.replace("/", os.sep) ignores.append((glob, ign)) def __call__(self, path): l = [] for (glob, ignlist) in self.ignores: if not glob or path.fnmatch(glob): if ignlist is None: return None l.extend(ignlist) return l def check_file(path, pep8ignore, max_line_length): checker = pep8.Checker(str(path), ignore=pep8ignore, show_source=1, max_line_length=max_line_length) return checker.check_all() pytest-pep8-1.0.6/PKG-INFO0000664000175000017500000001732312327120613014410 0ustar hpkhpk00000000000000Metadata-Version: 1.0 Name: pytest-pep8 Version: 1.0.6 Summary: pytest plugin to check PEP8 requirements Home-page: http://bitbucket.org/hpk42/pytest-pep8/ Author: Holger Krekel and Ronny Pfannschmidt Author-email: holger.krekel@gmail.com License: MIT license Description: py.test plugin for efficiently checking PEP8 compliance ======================================================================== Usage --------- install via:: pip install pytest-pep8 if you then type:: py.test --pep8 every file ending in ``.py`` will be discovered and pep8-checked, starting from the command line arguments. .. warning:: Running pep8 tests on your project is likely to cause a lot of issues. This plugin allows to configure on a per-project and per-file basis which errors or warnings to care about, see pep8ignore_. As a preliminary advise, if you have projects where you don't want to care at all about pep8 checks, you can put configure it like this:: # content of setup.cfg (or pytest.ini) [pytest] pep8ignore = * ALL A little example ----------------------- If you have a pep8-violating file like this:: # content of myfile.py somefunc( 123,456) you can run it with the plugin installed:: $ py.test --pep8 =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py F ================================= FAILURES ================================= ________________________________ PEP8-check ________________________________ /home/hpk/tmp/doc-exec-259/myfile.py:2:10: E201 whitespace after '(' somefunc( 123,456) ^ /home/hpk/tmp/doc-exec-259/myfile.py:2:14: E231 missing whitespace after ',' somefunc( 123,456) ^ ========================= 1 failed in 0.01 seconds ========================= For the meaning of (E)rror and (W)arning codes, see the error output when running against your files or checkout `pep8.py `_. Let's not now fix the PEP8 errors:: # content of myfile.py somefunc(123, 456) and run again:: $ py.test --pep8 =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py . ========================= 1 passed in 0.01 seconds ========================= the pep8 check now is passing. Moreover, if you run it once again (and report skip reasons):: $ py.test --pep8 -rs =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py s ========================= short test summary info ========================== SKIP [1] /home/hpk/p/pytest-pep8/pytest_pep8.py:63: file(s) previously passed PEP8 checks ======================== 1 skipped in 0.01 seconds ========================= you can see that the pep8 check was skipped because the file has not been modified since it was last checked. As the pep8 plugin uses the `pytest-cache plugin `_ to implement its caching, you can use its ``--clearcache`` option to remove all pytest caches, among them the pep8 related one, which will trigger the pep8 checking code to run once again:: $ py.test --pep8 --clearcache =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py . ========================= 1 passed in 0.01 seconds ========================= .. _pep8ignore: Configuring PEP8 options per project and file --------------------------------------------- You may configure PEP8-checking options for your project by adding an ``pep8ignore`` entry to your ``setup.cfg`` or ``setup.cfg`` file like this:: # content of setup.cfg [pytest] pep8ignore = E201 E231 This would globally prevent complaints about two whitespace issues. Rerunning with the above example will now look better:: $ py.test -q --pep8 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 pep8ignore line with a glob-pattern and a space-separated list of codes:: # content of setup.cfg [pytest] pep8ignore = *.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 --pep8 -v # verbose shows what is ignored =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 -- /home/hpk/venv/1/bin/python pep8: performing checks cachedir: /home/hpk/tmp/doc-exec-259/.cache collecting ... collected 1 items myfile.py:0: PEP8-check(ignoring E201) PASSED ========================= 1 passed in 0.01 seconds ========================= Note that doc/conf.py was not considered or imported. If you'ld like to have longer lines than 79 chars (which is the default for the pep8 checker), you can configure it like this:: # content of setup.cfg [pytest] pep8maxlinelength = 99 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 -m pep8 This will only run test items with the "pep8" marker which this plugins adds dynamically. 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. Platform: UNKNOWN pytest-pep8-1.0.6/CHANGELOG0000664000175000017500000000332312327120613014520 0ustar hpkhpk000000000000001.0.6 ---------- - fix tests to accomodate newer pep version which is more sensitive to detecting "E265 too many spaces" - add py34 to tox.ini - clarified in setup.py that license is MIT 1.0.5 -------------- - use pytest-2.4.2 node.add_marker() API for adding "pep8" marker 1.0.4 --------------------------------- - fix issue2: make pep8 interoperate with --strict runs 1.0.3 ---------------------------------------------- - added pep8maxlinelength ini setting to configure the maximum allowed line length. - add tox.ini and test_pep8.py to distribution 1.0.2 ---------------------------------------------- - fix a parsing bug - # is now recognized as as comment and ALL will now be recognized even if other codes are specified (nonsensically) 1.0.1 ---------------------------------------------- - add pytest-cache dep to setup.py 1.0 ---------------------------------------------- - extend pep8ignore to allow lines of form "glob CODE1 CODE2", for example: "test/*.py W293 E203" - speed up tests by preventing pep8 checking if a file was unmodified after its last change. - simplified pep8 checker usage (thanks flox) 0.9.1 ---------------------------------------------- - fixed compatibility with pep8==1.3 - made pytest_pep8 source itself pep9 compliant 0.8 ---------------------------------------------- - fix a bug with ignore option when the ignore count is higher than the error count (thanks Tetsuya Morimoto) 0.7 ---------------------------------------------- - change defaults and ini-file option name: now all pep8 checks are enabled and need to be explicitely ignored through a "pep8ignore" setting in the ini file. 0.6 ---------------------------------------------- - initial release pytest-pep8-1.0.6/README.txt0000664000175000017500000001362712327120613015014 0ustar hpkhpk00000000000000py.test plugin for efficiently checking PEP8 compliance ======================================================================== Usage --------- install via:: pip install pytest-pep8 if you then type:: py.test --pep8 every file ending in ``.py`` will be discovered and pep8-checked, starting from the command line arguments. .. warning:: Running pep8 tests on your project is likely to cause a lot of issues. This plugin allows to configure on a per-project and per-file basis which errors or warnings to care about, see pep8ignore_. As a preliminary advise, if you have projects where you don't want to care at all about pep8 checks, you can put configure it like this:: # content of setup.cfg (or pytest.ini) [pytest] pep8ignore = * ALL A little example ----------------------- If you have a pep8-violating file like this:: # content of myfile.py somefunc( 123,456) you can run it with the plugin installed:: $ py.test --pep8 =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py F ================================= FAILURES ================================= ________________________________ PEP8-check ________________________________ /home/hpk/tmp/doc-exec-259/myfile.py:2:10: E201 whitespace after '(' somefunc( 123,456) ^ /home/hpk/tmp/doc-exec-259/myfile.py:2:14: E231 missing whitespace after ',' somefunc( 123,456) ^ ========================= 1 failed in 0.01 seconds ========================= For the meaning of (E)rror and (W)arning codes, see the error output when running against your files or checkout `pep8.py `_. Let's not now fix the PEP8 errors:: # content of myfile.py somefunc(123, 456) and run again:: $ py.test --pep8 =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py . ========================= 1 passed in 0.01 seconds ========================= the pep8 check now is passing. Moreover, if you run it once again (and report skip reasons):: $ py.test --pep8 -rs =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py s ========================= short test summary info ========================== SKIP [1] /home/hpk/p/pytest-pep8/pytest_pep8.py:63: file(s) previously passed PEP8 checks ======================== 1 skipped in 0.01 seconds ========================= you can see that the pep8 check was skipped because the file has not been modified since it was last checked. As the pep8 plugin uses the `pytest-cache plugin `_ to implement its caching, you can use its ``--clearcache`` option to remove all pytest caches, among them the pep8 related one, which will trigger the pep8 checking code to run once again:: $ py.test --pep8 --clearcache =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py . ========================= 1 passed in 0.01 seconds ========================= .. _pep8ignore: Configuring PEP8 options per project and file --------------------------------------------- You may configure PEP8-checking options for your project by adding an ``pep8ignore`` entry to your ``setup.cfg`` or ``setup.cfg`` file like this:: # content of setup.cfg [pytest] pep8ignore = E201 E231 This would globally prevent complaints about two whitespace issues. Rerunning with the above example will now look better:: $ py.test -q --pep8 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 pep8ignore line with a glob-pattern and a space-separated list of codes:: # content of setup.cfg [pytest] pep8ignore = *.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 --pep8 -v # verbose shows what is ignored =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 -- /home/hpk/venv/1/bin/python pep8: performing checks cachedir: /home/hpk/tmp/doc-exec-259/.cache collecting ... collected 1 items myfile.py:0: PEP8-check(ignoring E201) PASSED ========================= 1 passed in 0.01 seconds ========================= Note that doc/conf.py was not considered or imported. If you'ld like to have longer lines than 79 chars (which is the default for the pep8 checker), you can configure it like this:: # content of setup.cfg [pytest] pep8maxlinelength = 99 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 -m pep8 This will only run test items with the "pep8" marker which this plugins adds dynamically. 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. pytest-pep8-1.0.6/pytest_pep8.egg-info/0000775000175000017500000000000012327120613017263 5ustar hpkhpk00000000000000pytest-pep8-1.0.6/pytest_pep8.egg-info/entry_points.txt0000664000175000017500000000003712327120613022561 0ustar hpkhpk00000000000000[pytest11] pep8 = pytest_pep8 pytest-pep8-1.0.6/pytest_pep8.egg-info/top_level.txt0000664000175000017500000000001412327120613022010 0ustar hpkhpk00000000000000pytest_pep8 pytest-pep8-1.0.6/pytest_pep8.egg-info/requires.txt0000664000175000017500000000004412327120613021661 0ustar hpkhpk00000000000000pytest-cache pytest>=2.4.2 pep8>=1.3pytest-pep8-1.0.6/pytest_pep8.egg-info/PKG-INFO0000664000175000017500000001732312327120613020366 0ustar hpkhpk00000000000000Metadata-Version: 1.0 Name: pytest-pep8 Version: 1.0.6 Summary: pytest plugin to check PEP8 requirements Home-page: http://bitbucket.org/hpk42/pytest-pep8/ Author: Holger Krekel and Ronny Pfannschmidt Author-email: holger.krekel@gmail.com License: MIT license Description: py.test plugin for efficiently checking PEP8 compliance ======================================================================== Usage --------- install via:: pip install pytest-pep8 if you then type:: py.test --pep8 every file ending in ``.py`` will be discovered and pep8-checked, starting from the command line arguments. .. warning:: Running pep8 tests on your project is likely to cause a lot of issues. This plugin allows to configure on a per-project and per-file basis which errors or warnings to care about, see pep8ignore_. As a preliminary advise, if you have projects where you don't want to care at all about pep8 checks, you can put configure it like this:: # content of setup.cfg (or pytest.ini) [pytest] pep8ignore = * ALL A little example ----------------------- If you have a pep8-violating file like this:: # content of myfile.py somefunc( 123,456) you can run it with the plugin installed:: $ py.test --pep8 =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py F ================================= FAILURES ================================= ________________________________ PEP8-check ________________________________ /home/hpk/tmp/doc-exec-259/myfile.py:2:10: E201 whitespace after '(' somefunc( 123,456) ^ /home/hpk/tmp/doc-exec-259/myfile.py:2:14: E231 missing whitespace after ',' somefunc( 123,456) ^ ========================= 1 failed in 0.01 seconds ========================= For the meaning of (E)rror and (W)arning codes, see the error output when running against your files or checkout `pep8.py `_. Let's not now fix the PEP8 errors:: # content of myfile.py somefunc(123, 456) and run again:: $ py.test --pep8 =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py . ========================= 1 passed in 0.01 seconds ========================= the pep8 check now is passing. Moreover, if you run it once again (and report skip reasons):: $ py.test --pep8 -rs =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py s ========================= short test summary info ========================== SKIP [1] /home/hpk/p/pytest-pep8/pytest_pep8.py:63: file(s) previously passed PEP8 checks ======================== 1 skipped in 0.01 seconds ========================= you can see that the pep8 check was skipped because the file has not been modified since it was last checked. As the pep8 plugin uses the `pytest-cache plugin `_ to implement its caching, you can use its ``--clearcache`` option to remove all pytest caches, among them the pep8 related one, which will trigger the pep8 checking code to run once again:: $ py.test --pep8 --clearcache =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 pep8: performing checks collecting ... collected 1 items myfile.py . ========================= 1 passed in 0.01 seconds ========================= .. _pep8ignore: Configuring PEP8 options per project and file --------------------------------------------- You may configure PEP8-checking options for your project by adding an ``pep8ignore`` entry to your ``setup.cfg`` or ``setup.cfg`` file like this:: # content of setup.cfg [pytest] pep8ignore = E201 E231 This would globally prevent complaints about two whitespace issues. Rerunning with the above example will now look better:: $ py.test -q --pep8 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 pep8ignore line with a glob-pattern and a space-separated list of codes:: # content of setup.cfg [pytest] pep8ignore = *.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 --pep8 -v # verbose shows what is ignored =========================== test session starts ============================ platform linux2 -- Python 2.7.3 -- pytest-2.2.5.dev2 -- /home/hpk/venv/1/bin/python pep8: performing checks cachedir: /home/hpk/tmp/doc-exec-259/.cache collecting ... collected 1 items myfile.py:0: PEP8-check(ignoring E201) PASSED ========================= 1 passed in 0.01 seconds ========================= Note that doc/conf.py was not considered or imported. If you'ld like to have longer lines than 79 chars (which is the default for the pep8 checker), you can configure it like this:: # content of setup.cfg [pytest] pep8maxlinelength = 99 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 -m pep8 This will only run test items with the "pep8" marker which this plugins adds dynamically. 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. Platform: UNKNOWN pytest-pep8-1.0.6/pytest_pep8.egg-info/SOURCES.txt0000664000175000017500000000045112327120613021147 0ustar hpkhpk00000000000000CHANGELOG LICENSE MANIFEST.in README.txt pytest_pep8.py setup.py test_pep8.py tox.ini pytest_pep8.egg-info/PKG-INFO pytest_pep8.egg-info/SOURCES.txt pytest_pep8.egg-info/dependency_links.txt pytest_pep8.egg-info/entry_points.txt pytest_pep8.egg-info/requires.txt pytest_pep8.egg-info/top_level.txtpytest-pep8-1.0.6/pytest_pep8.egg-info/dependency_links.txt0000664000175000017500000000000112327120613023331 0ustar hpkhpk00000000000000 pytest-pep8-1.0.6/tox.ini0000664000175000017500000000065112327120613014622 0ustar hpkhpk00000000000000[tox] envlist=py26,py27,py27-pytesttrunk,py33,py-xdist,py34 [testenv] deps=pytest commands= py.test --junitxml={envlogdir}/junit-{envname}.xml {posargs} [testenv:py27-pytesttrunk] deps = pytest [testenv:py-xdist] basepython=python deps={[testenv]deps} pytest-xdist commands= py.test -n3 --junitxml={envlogdir}/junit-{envname}.xml {posargs} [pytest] addopts=--pep8 pep8ignore = E128 #pep8maxlinelength = 66 pytest-pep8-1.0.6/setup.cfg0000664000175000017500000000007312327120613015126 0ustar hpkhpk00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 pytest-pep8-1.0.6/MANIFEST.in0000664000175000017500000000021012327120613015034 0ustar hpkhpk00000000000000include CHANGELOG include README.txt include setup.py include tox.ini include LICENSE include test_pep8.py graft doc graft test_pep8.py