[TIP] pytest-pep 0.7: check everything, determine your own PEP8 ignorance

holger krekel holger at merlinux.eu
Mon Dec 6 07:42:30 PST 2010


Hi Alfredo,

thanks for the feedback.  i released pytest-pep8 0.7 now which has a 

    [pytest]
    pep8ignore  = OPT1 OPT2 ...

option so that you can make up project specific list, starting now
with a "check everything" setting.  I updated the docs as well, see 

    http://pypi.python.org/pypi/pytest-pep8

cheers,
holger

On Mon, Dec 06, 2010 at 09:55 -0500, Alfredo Deza wrote:
> On Mon, Dec 6, 2010 at 9:50 AM, holger krekel <holger at merlinux.eu> wrote:
> 
> > On Mon, Dec 06, 2010 at 09:00 -0500, Alfredo Deza wrote:
> > > On Mon, Dec 6, 2010 at 8:46 AM, holger krekel <holger at merlinux.eu>
> > wrote:
> > >
> > > >
> > > > just released an initial version 0.6 of the pytest-pep8 plugin,
> > > > integrating the ``pep8`` module into py.test runs, allowing full
> > > > per-project customization and configuration.
> > > >
> > > >
> > > This looks very useful as py.test plugin.
> > >
> > > Is there any way of getting junit output from it? This would help when
> > using
> > > it with Hudson.
> > >
> > > We already use the junit flag to output test results but wanted to add
> > > something like the pep8 plugin
> > > for correctness :)
> >
> > Heh, <borrowing-time-machine> actually
> >
> >    py.test --pep8 --junitxml=mypath.xml
> >
> > should present all PEP8 errors or warnings in the JunitXML file.
> > If not, i'd consider it a bug which you can report or fix
> > with the http://bitbucket.org/hpk42/pytest-pep8 repo.
> >
> 
> Ok great, so no "extras" are involved to make it output to the JunitXML
> file. Nice.
> 
> >
> > sidenote: i am not sure about the default behaviour - would it
> > maybe make sense to start out with warning/erroring on everything
> > and leaving it to project-specific configuration which warnings
> > and pep8 errors to ignore?
> >
> 
> I think it is safe to assume that if you are using this plugin you want
> everything
> "ON" by default, so you can see what things you are interested in and tweak
> (turn off)
> as you progress.
> 
> >
> > cheers,
> > holger
> >
> > >
> > >
> > >
> > > > See http://pypi.python.org/pypi/pytest-pep8 for installation
> > > > and configuration instructions.
> > > >
> > > > best,
> > > > holger
> > > >
> > > > Usage
> > > > -----------------
> > > >
> > > > install pytest-pep8 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
> > > > <https://github.com/jcrocholl/pep8/blob/master/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.
> > > >
> > > >
> > > > _______________________________________________
> > > > testing-in-python mailing list
> > > > testing-in-python at lists.idyll.org
> > > > http://lists.idyll.org/listinfo/testing-in-python
> > > >
> >
> > --
> >

-- 



More information about the testing-in-python mailing list