Package: pytest-flakes
pytest-flakespy.test plugin for efficiently checking python source with pyflakes.Usageinstall via:pip install pytest-flakesif you then type:py.test --flakesevery file ending in.pywill be discovered and run through pyflakes,
starting from the command line arguments.Simple usage exampleConsider you have this code:# content of module.py

import os
from os.path import *

def some_function():
    passRunning it with pytest-flakes installed shows two issues:$ py.test -q --flakes
F
================================= FAILURES =================================
______________________________ pyflakes-check ______________________________
/tmp/doc-exec-685/module.py:2: UnusedImport
'os' imported but unused
/tmp/doc-exec-685/module.py:3: ImportStarUsed
'from os.path import *' used; unable to detect undefined names
1 failed in 0.00 secondsThese are only two of the many issues that pytest-flakes can find.Configuring pyflakes options per project and fileYou may configure pyflakes-checking options for your project
by adding anflakes-ignoreentry to yoursetup.cfgorpytest.inifile like this:# content of setup.cfg
[pytest]
flakes-ignore = ImportStarUsedThis would globally prevent complaints about star imports.
Rerunning with the above example will now look better:$ py.test -q --flakes
F
================================= FAILURES =================================
_________________ pyflakes-check(ignoring ImportStarUsed) __________________
/tmp/doc-exec-685/module.py:2: UnusedImport
'os' imported but unused
1 failed in 0.00 secondsBut of course we still would want to delete theimport osline to
have a clean pass.If you have some files where you want to specifically ignore
some errors or warnings you can start a flakes-ignore line with
a glob-pattern and a space-separated list of codes:# content of setup.cfg
[pytest]
flakes-ignore =
    *.py UnusedImport
    doc/conf.py ALLIgnoring certain lines in filesYou can ignore errors per line by appending special comments to them like this:import sys # noqa
app # pragma: no flakesRunning pyflakes checks and no other testsYou can restrict your test run to only perform “flakes” tests
and not any other tests by typing:py.test --flakes -m flakesThis will only run tests that are marked with the “flakes” keyword
which is added for the flakes test items added by this plugin.If you are using pytest < 2.4, then use the following invocation
to the same effect:py.test --flakes -k flakesNotesThe repository of this plugin is athttps://github.com/asmeurer/pytest-flakesFor more info on py.test seehttp://pytest.orgThe code is partially based on Ronny Pfannschmidt’s pytest-codecheckers plugin
and Holger Krekel’s pytest-pep8.Changes4.0.5 - 2021-12-02Further fixes for deprecations in the upcoming pytest 7.0. [nicoddemus]4.0.4 - 2021-10-26Fix pytest-flakes for deprecations in the upcoming pytest 7.0. [bluetech]Fix the pytest-flakes test suite in Python 3.10. [bluetech]Replace Travis CI with GitHub Actions. [bluetech]4.0.3 - 2020-11-27Future proof some code against future versions of pytest. [RonnyPfannschmidt]4.0.2 - 2020-09-18Fix calling pytest –flakes directly on an __init__.py file. [akeeman]4.0.1 - 2020-07-28Maintenance of pytest-flakes has moved from fschulze to asmeurer. The repo
for pytest-flakes is now athttps://github.com/asmeurer/pytest-flakes/Fix test failures.
[asmeurer]Fix deprecation warnings from pytest.
[asmeurer]Fix invalid escape sequences.
[akeeman]4.0.0 - 2018-08-01Require pytest >= 2.8.0 and remove pytest-cache requirement.
Cache is included in pytest since that version.
[smarlowucf (Sean Marlow)]3.0.2 - 2018-05-16Fix typo in name offlakesmarker.
[fschulze]3.0.1 - 2018-05-16Always registerflakesmarker, not only when the--flakesoption
is used.
[fschulze]3.0.0 - 2018-05-16Drop support for Python 3.3. It still works so far, but isn’t tested anymore.
[fschulze]Addflakesmarker required since pytest 3.1.
[fschulze]Use pyflakes.api.isPythonFile to detect Python files. This might test more
files than before and thus could cause previously uncaught failures.
[asmeurer (Aaron Meurer)]2.0.0 - 2017-05-12Dropped support/testing for Python 2.5, 2.6, 3.2.
[fschulze]Added testing for Python 3.6.
[fschulze]Fixed some packaging and metadata errors.
[fladi (Michael Fladischer), fschulze]1.0.1 - 2015-09-17Compatibility with upcoming pytest.
[RonnyPfannschmidt (Ronny Pfannschmidt)]1.0.0 - 2015-05-01Fix issue #6 - support PEP263 for source file encoding.
[The-Compiler (Florian Bruhin), fschulze]Clarified license to be MIT like pytest-pep8 from which this is derived.
[fschulze]0.2 - 2013-02-11Adapt to pytest-2.4.2 usingadd_marker()API.
[fschulze, hpk42 (Holger Krekel)]Allow errors to be skipped per line by appending # noqa or # pragma: no flakes
[fschulze, silviot (Silvio Tomatis)]Python 3.x compatibility.
[fschulze, encukou (Petr Viktorin)]0.1 - 2013-02-04Initial release.
[fschulze (Florian Schulze)]