Add "fix-lint" tox environment to fix linting errors

This commit is contained in:
Bruno Oliveira 2017-07-20 19:14:54 -03:00
parent da12c52347
commit 22f54784c2
9 changed files with 69 additions and 44 deletions

View File

@ -212,7 +212,12 @@ but here is a simple overview:
$ tox -e linting,py27,py36
This command will run tests via the "tox" tool against Python 2.7 and 3.6
and also perform "lint" coding-style checks.
and also perform "lint" coding-style checks. If you have too much linting errors,
try running::
$ tox -e fix-lint
To fix pep8 related errors.
#. You can now edit your local working copy.

1
changelog/2582.trivial Normal file
View File

@ -0,0 +1 @@
Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code.

View File

@ -335,21 +335,6 @@ def test_getstartingblock_singleline():
assert len(l) == 1
def test_getstartingblock_multiline():
class A(object):
def __init__(self, *args):
frame = sys._getframe(1)
self.source = _pytest._code.Frame(frame).statement
x = A('x',
'y'
,
'z')
l = [i for i in x.source.lines if i.strip()]
assert len(l) == 4
def test_getline_finally():
def c(): pass
excinfo = pytest.raises(TypeError, """

View File

@ -0,0 +1,26 @@
# flake8: noqa
import sys
import _pytest._code
def test_getstartingblock_multiline():
"""
This test was originally found in test_source.py, but it depends on the weird
formatting of the ``x = A`` construct seen here and our autopep8 tool can only exclude entire
files (it does not support excluding lines/blocks using the traditional #noqa comment yet,
see hhatto/autopep8#307). It was considered better to just move this single test to its own
file and exclude it from autopep8 than try to complicate things.
"""
class A(object):
def __init__(self, *args):
frame = sys._getframe(1)
self.source = _pytest._code.Frame(frame).statement
x = A('x',
'y'
,
'z')
l = [i for i in x.source.lines if i.strip()]
assert len(l) == 4

View File

@ -288,7 +288,7 @@ class TestLoggingInteraction(object):
stream.close() # to free memory/release resources
""")
result = testdir.runpytest_subprocess(p)
result.stderr.str().find("atexit") == -1
assert result.stderr.str().find("atexit") == -1
def test_logging_and_immediate_setupteardown(self, testdir):
p = testdir.makepyfile("""

View File

@ -149,6 +149,14 @@ commands =
rm -rf /tmp/doc-exec*
make regen
[testenv:fix-lint]
skipsdist = True
usedevelop = True
deps =
autopep8
commands =
autopep8 --in-place -r --max-line-length=120 --exclude=vendored_packages,test_source_multiline_block.py _pytest testing
[testenv:jython]
changedir = testing
commands =