Merge pull request #2596 from nicoddemus/autopep-tox

Add "fix-lint" tox environment
This commit is contained in:
Ronny Pfannschmidt 2017-07-21 06:25:59 +02:00 committed by GitHub
commit ccc4b3a501
15 changed files with 74 additions and 49 deletions

View File

@ -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.

1
changelog/2375.bugfix Normal file
View File

@ -0,0 +1 @@
Add missing ``encoding`` attribute to ``sys.std*`` streams when using ``capsys`` capture mode.

View File

@ -1 +0,0 @@
Provides encoding attribute on CaptureIO.

View File

@ -1 +1 @@
Renamed the utility function `_pytest.compat._escape_strings` to `_ascii_escaped` to better communicate the function's purpose. Renamed the utility function ``_pytest.compat._escape_strings`` to ``_ascii_escaped`` to better communicate the function's purpose.

View File

@ -1 +1 @@
Emit yield test warning only once per generator Emit warning about ``yield`` tests being deprecated only once per generator.

View File

@ -1 +1 @@
The options --fixtures and --fixtures-per-test will now keep indentation within docstrings. The options ```--fixtures`` and ```--fixtures-per-test`` will now keep indentation within docstrings.

View File

@ -1 +1 @@
Fixed all flake8 errors and warnings Fixed all flake8 errors and warnings.

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 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, """

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 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("""

View File

@ -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 =