diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0340fb9d..1673cab73 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,19 @@ exclude: doc/en/example/py2py3/test_py2.py repos: - repo: https://github.com/ambv/black - rev: 18.6b4 + rev: 18.9b0 hooks: - id: black args: [--safe, --quiet] language_version: python3 - repo: https://github.com/asottile/blacken-docs - rev: v0.2.0 + rev: v0.3.0 hooks: - id: blacken-docs - additional_dependencies: [black==18.6b4] + additional_dependencies: [black==18.9b0] language_version: python3 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.3.0 + rev: v1.4.0-1 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -22,11 +22,12 @@ repos: exclude: _pytest/debugging.py - id: flake8 - repo: https://github.com/asottile/pyupgrade - rev: v1.2.0 + rev: v1.8.0 hooks: - - id: pyupgrade + - id: pyupgrade + args: [--keep-percent-format] - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.0.0 + rev: v1.1.0 hooks: - id: rst-backticks - repo: local diff --git a/bench/bench_argcomplete.py b/bench/bench_argcomplete.py index 495e2c4ed..3ad6dabe5 100644 --- a/bench/bench_argcomplete.py +++ b/bench/bench_argcomplete.py @@ -1,5 +1,3 @@ - - # 10000 iterations, just for relative comparison # 2.7.5 3.3.2 # FilesCompleter 75.1109 69.2116 diff --git a/bench/manyparam.py b/bench/manyparam.py index a25b098de..1226c73bd 100644 --- a/bench/manyparam.py +++ b/bench/manyparam.py @@ -1,4 +1,3 @@ - import pytest diff --git a/doc/en/example/assertion/failure_demo.py b/doc/en/example/assertion/failure_demo.py index def6ae2ef..33fff5565 100644 --- a/doc/en/example/assertion/failure_demo.py +++ b/doc/en/example/assertion/failure_demo.py @@ -245,9 +245,9 @@ class TestCustomAssertMsg(object): a = 1 b = 2 - assert ( - A.a == b - ), "A.a appears not to be b\n" "or does not appear to be b\none of those" + assert A.a == b, ( + "A.a appears not to be b\n" "or does not appear to be b\none of those" + ) def test_custom_repr(self): class JSON(object): diff --git a/doc/en/example/assertion/global_testmodule_config/test_hello_world.py b/doc/en/example/assertion/global_testmodule_config/test_hello_world.py index b945afa67..a31a601a1 100644 --- a/doc/en/example/assertion/global_testmodule_config/test_hello_world.py +++ b/doc/en/example/assertion/global_testmodule_config/test_hello_world.py @@ -1,4 +1,3 @@ - hello = "world" diff --git a/doc/en/example/assertion/test_failures.py b/doc/en/example/assertion/test_failures.py index 43f748fa2..9ffe31664 100644 --- a/doc/en/example/assertion/test_failures.py +++ b/doc/en/example/assertion/test_failures.py @@ -1,4 +1,3 @@ - import py failure_demo = py.path.local(__file__).dirpath("failure_demo.py") diff --git a/doc/en/example/costlysetup/conftest.py b/doc/en/example/costlysetup/conftest.py index e41c4129c..57b08b5fa 100644 --- a/doc/en/example/costlysetup/conftest.py +++ b/doc/en/example/costlysetup/conftest.py @@ -1,4 +1,3 @@ - import pytest diff --git a/src/_pytest/_argcomplete.py b/src/_pytest/_argcomplete.py index 8f480d71d..0d1c2da6a 100644 --- a/src/_pytest/_argcomplete.py +++ b/src/_pytest/_argcomplete.py @@ -1,4 +1,3 @@ - """allow bash-completion for argparse with argcomplete if installed needs argcomplete>=0.5.6 for python 3.2/3.3 (older versions fail to find the magic string, so _ARGCOMPLETE env. var is never set, and diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 0f8d2d5f3..7184c6fd9 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -423,7 +423,7 @@ class PytestPluginManager(PluginManager): and not self._using_pyargs ): from _pytest.deprecated import ( - PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST + PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST, ) warnings.warn_explicit( diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index 7fa49bc28..ac00c772a 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -38,7 +38,7 @@ class Junit(py.xml.Namespace): # this dynamically instead of hardcoding it. The spec range of valid # chars is: Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] # | [#x10000-#x10FFFF] -_legal_chars = (0x09, 0x0A, 0x0d) +_legal_chars = (0x09, 0x0A, 0x0D) _legal_ranges = ((0x20, 0x7E), (0x80, 0xD7FF), (0xE000, 0xFFFD), (0x10000, 0x10FFFF)) _legal_xml_re = [ unicode("%s-%s") % (unichr(low), unichr(high)) diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 2d0f54a64..f1fc05ffa 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -213,7 +213,9 @@ class LogCaptureFixture(object): def __init__(self, item): """Creates a new funcarg.""" self._item = item - self._initial_log_levels = {} # type: Dict[str, int] # dict of log name -> log level + self._initial_log_levels = ( + {} + ) # type: Dict[str, int] # dict of log name -> log level def _finalize(self): """Finalizes the fixture. diff --git a/src/_pytest/mark/evaluate.py b/src/_pytest/mark/evaluate.py index d4bfdaf34..6736cb799 100644 --- a/src/_pytest/mark/evaluate.py +++ b/src/_pytest/mark/evaluate.py @@ -90,7 +90,10 @@ class MarkEvaluator(object): else: if "reason" not in mark.kwargs: # XXX better be checked at collection time - msg = "you need to specify reason=STRING " "when using booleans as conditions." + msg = ( + "you need to specify reason=STRING " + "when using booleans as conditions." + ) fail(msg) result = bool(expr) if result: diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py index 927ecc4d1..c37045454 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py @@ -1,4 +1,3 @@ - import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py index 983849dba..0661cb301 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py @@ -1,4 +1,3 @@ - import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py index 56b8d0c7f..7b7183dd9 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py @@ -1,4 +1,3 @@ - import pytest diff --git a/testing/example_scripts/issue_519.py b/testing/example_scripts/issue_519.py index 7d03b5632..5dc8b163c 100644 --- a/testing/example_scripts/issue_519.py +++ b/testing/example_scripts/issue_519.py @@ -1,4 +1,3 @@ - import pytest import pprint diff --git a/testing/python/approx.py b/testing/python/approx.py index b1440adee..f9eefb372 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -62,11 +62,11 @@ class TestApprox(object): @pytest.mark.parametrize( "value, repr_string", [ - (5., "approx(5.0 {pm} 5.0e-06)"), - ([5.], "approx([5.0 {pm} 5.0e-06])"), - ([[5.]], "approx([[5.0 {pm} 5.0e-06]])"), - ([[5., 6.]], "approx([[5.0 {pm} 5.0e-06, 6.0 {pm} 6.0e-06]])"), - ([[5.], [6.]], "approx([[5.0 {pm} 5.0e-06], [6.0 {pm} 6.0e-06]])"), + (5.0, "approx(5.0 {pm} 5.0e-06)"), + ([5.0], "approx([5.0 {pm} 5.0e-06])"), + ([[5.0]], "approx([[5.0 {pm} 5.0e-06]])"), + ([[5.0, 6.0]], "approx([[5.0 {pm} 5.0e-06, 6.0 {pm} 6.0e-06]])"), + ([[5.0], [6.0]], "approx([[5.0 {pm} 5.0e-06], [6.0 {pm} 6.0e-06]])"), ], ) def test_repr_nd_array(self, plus_minus, value, repr_string): @@ -354,16 +354,16 @@ class TestApprox(object): Test all permutations of where the approx and np.array() can show up """ np = pytest.importorskip("numpy") - expected = 100. - actual = 99. + expected = 100.0 + actual = 99.0 abs_diff = expected - actual rel_diff = (expected - actual) / expected tests = [ (eq, abs_diff, 0), (eq, 0, rel_diff), - (ne, 0, rel_diff / 2.), # rel diff fail - (ne, abs_diff / 2., 0), # abs diff fail + (ne, 0, rel_diff / 2.0), # rel diff fail + (ne, abs_diff / 2.0, 0), # abs diff fail ] for op, _abs, _rel in tests: diff --git a/testing/test_pytester.py b/testing/test_pytester.py index c5a64b7bd..5be2bada8 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -176,7 +176,7 @@ def test_makepyfile_unicode(testdir): unichr(65) except NameError: unichr = chr - testdir.makepyfile(unichr(0xfffd)) + testdir.makepyfile(unichr(0xFFFD)) def test_makepyfile_utf8(testdir):