Add "fix-lint" tox environment to fix linting errors
This commit is contained in:
parent
da12c52347
commit
22f54784c2
|
@ -212,7 +212,12 @@ but here is a simple overview:
|
||||||
$ tox -e linting,py27,py36
|
$ tox -e linting,py27,py36
|
||||||
|
|
||||||
This command will run tests via the "tox" tool against Python 2.7 and 3.6
|
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.
|
#. You can now edit your local working copy.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code.
|
|
@ -335,21 +335,6 @@ def test_getstartingblock_singleline():
|
||||||
assert len(l) == 1
|
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 test_getline_finally():
|
||||||
def c(): pass
|
def c(): pass
|
||||||
excinfo = pytest.raises(TypeError, """
|
excinfo = pytest.raises(TypeError, """
|
||||||
|
|
|
@ -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
|
|
@ -288,7 +288,7 @@ class TestLoggingInteraction(object):
|
||||||
stream.close() # to free memory/release resources
|
stream.close() # to free memory/release resources
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest_subprocess(p)
|
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):
|
def test_logging_and_immediate_setupteardown(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
|
|
8
tox.ini
8
tox.ini
|
@ -149,6 +149,14 @@ commands =
|
||||||
rm -rf /tmp/doc-exec*
|
rm -rf /tmp/doc-exec*
|
||||||
make regen
|
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]
|
[testenv:jython]
|
||||||
changedir = testing
|
changedir = testing
|
||||||
commands =
|
commands =
|
||||||
|
|
Loading…
Reference in New Issue