From a8c16d9b75ac604b9038d175a2d0ca89fec932a2 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 16 Nov 2019 18:42:17 +0100 Subject: [PATCH 1/3] pre-commit: upgrade black This brings https://github.com/psf/black/pull/826, which helps with https://github.com/psf/black/issues/601. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34895e1a30f..3aee45c62c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: doc/en/example/py2py3/test_py2.py repos: -- repo: https://github.com/python/black - rev: 19.3b0 +- repo: https://github.com/psf/black + rev: 19.10b0 hooks: - id: black args: [--safe, --quiet] From 3d8649b206ad67acc4c762dd23a6bcf332862806 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 16 Nov 2019 18:51:02 +0100 Subject: [PATCH 2/3] Remove (now) unnecessary fmt: off --- src/_pytest/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index b35faffb9df..a643936958c 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -116,13 +116,13 @@ def directory_arg(path, optname): # Plugins that cannot be disabled via "-p no:X" currently. -essential_plugins = ( # fmt: off +essential_plugins = ( "mark", "main", "runner", "fixtures", "helpconfig", # Provides -p. -) # fmt: on +) default_plugins = essential_plugins + ( "python", From 097acaf11bd54fd827d48b82a5ab21460ba84e80 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 16 Nov 2019 18:53:29 +0100 Subject: [PATCH 3/3] re-run black --- src/_pytest/python_api.py | 2 +- src/_pytest/recwarn.py | 2 +- testing/deprecated_test.py | 4 ++-- testing/python/fixtures.py | 6 +++--- testing/test_collection.py | 8 ++++---- testing/test_mark.py | 4 ++-- testing/test_recwarn.py | 2 +- testing/test_skipping.py | 2 +- testing/test_tmpdir.py | 2 +- testing/test_unittest.py | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index df09aa32d8f..f6e475c3a24 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -694,7 +694,7 @@ def raises(expected_exception, *args, **kwargs): return RaisesContext(expected_exception, message, match_expr) elif isinstance(args[0], str): warnings.warn(deprecated.RAISES_EXEC, stacklevel=2) - code, = args + (code,) = args assert isinstance(code, str) frame = sys._getframe(1) loc = frame.f_locals.copy() diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 574c6a1cced..7abf2e93550 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -95,7 +95,7 @@ def warns(expected_warning, *args, **kwargs): return WarningsChecker(expected_warning, match_expr=match_expr) elif isinstance(args[0], str): warnings.warn(WARNS_EXEC, stacklevel=2) - code, = args + (code,) = args assert isinstance(code, str) frame = sys._getframe(1) loc = frame.f_locals.copy() diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index a072f6b210c..70460214fbd 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -152,7 +152,7 @@ def test_pytest_plugins_in_non_top_level_conftest_unsupported_pyargs( def test_pytest_plugins_in_non_top_level_conftest_unsupported_no_top_level_conftest( - testdir + testdir, ): from _pytest.deprecated import PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST @@ -181,7 +181,7 @@ def test_func(): def test_pytest_plugins_in_non_top_level_conftest_unsupported_no_false_positives( - testdir + testdir, ): from _pytest.deprecated import PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index bd1b1d97541..4869431c639 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -464,7 +464,7 @@ def test_func(something): pass assert repr(req).find(req.function.__name__) != -1 def test_request_attributes_method(self, testdir): - item, = testdir.getitems( + (item,) = testdir.getitems( """ import pytest class TestB(object): @@ -492,7 +492,7 @@ def test_method(self, something): pass """ ) - item1, = testdir.genitems([modcol]) + (item1,) = testdir.genitems([modcol]) assert item1.name == "test_method" arg2fixturedefs = fixtures.FixtureRequest(item1)._arg2fixturedefs assert len(arg2fixturedefs) == 1 @@ -756,7 +756,7 @@ def test_second(): def test_request_getmodulepath(self, testdir): modcol = testdir.getmodulecol("def test_somefunc(): pass") - item, = testdir.genitems([modcol]) + (item,) = testdir.genitems([modcol]) req = fixtures.FixtureRequest(item) assert req.fspath == modcol.fspath diff --git a/testing/test_collection.py b/testing/test_collection.py index 52c6aa9995b..0fbbbec54df 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -494,7 +494,7 @@ def test_collect_protocol_single_function(self, testdir): p = testdir.makepyfile("def test_func(): pass") id = "::".join([p.basename, "test_func"]) items, hookrec = testdir.inline_genitems(id) - item, = items + (item,) = items assert item.name == "test_func" newid = item.nodeid assert newid == id @@ -613,9 +613,9 @@ def test_serialization_byid(self, testdir): testdir.makepyfile("def test_func(): pass") items, hookrec = testdir.inline_genitems() assert len(items) == 1 - item, = items + (item,) = items items2, hookrec = testdir.inline_genitems(item.nodeid) - item2, = items2 + (item2,) = items2 assert item2.name == item.name assert item2.fspath == item.fspath @@ -630,7 +630,7 @@ def test_method(self): arg = p.basename + "::TestClass::test_method" items, hookrec = testdir.inline_genitems(arg) assert len(items) == 1 - item, = items + (item,) = items assert item.nodeid.endswith("TestClass::test_method") # ensure we are reporting the collection of the single test item (#2464) assert [x.name for x in self.get_reported_items(hookrec)] == ["test_method"] diff --git a/testing/test_mark.py b/testing/test_mark.py index dd9d352309d..727bd9420c2 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1008,7 +1008,7 @@ def test_custom_mark_parametrized(obj_type): def test_pytest_param_id_requires_string(): with pytest.raises(TypeError) as excinfo: pytest.param(id=True) - msg, = excinfo.value.args + (msg,) = excinfo.value.args if six.PY2: assert msg == "Expected id to be a string, got : True" else: @@ -1025,7 +1025,7 @@ def test_pytest_param_warning_on_unknown_kwargs(): # typo, should be marks= pytest.param(1, 2, mark=pytest.mark.xfail()) assert warninfo[0].filename == __file__ - msg, = warninfo[0].message.args + (msg,) = warninfo[0].message.args assert msg == ( "pytest.param() got unexpected keyword arguments: ['mark'].\n" "This will be an error in future versions." diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index 2246085f59e..d652219df3e 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -225,7 +225,7 @@ def test_strings(self): assert len(warninfo) == 3 for w in warninfo: assert w.filename == __file__ - msg, = w.message.args + (msg,) = w.message.args assert msg.startswith("warns(..., 'code(as_a_string)') is deprecated") def test_function(self): diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 55119ae1269..7834971125a 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -136,7 +136,7 @@ def test_func(): ) def test_skipif_class(self, testdir): - item, = testdir.getitems( + (item,) = testdir.getitems( """ import pytest class TestClass(object): diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index d5291f5a9e7..7622342b1d7 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -273,7 +273,7 @@ def test_lock_register_cleanup_removal(self, tmp_path): registry = [] register_cleanup_lock_removal(lock, register=registry.append) - cleanup_func, = registry + (cleanup_func,) = registry assert lock.is_file() diff --git a/testing/test_unittest.py b/testing/test_unittest.py index e9982b3d5b9..6b721d1c0ce 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -388,7 +388,7 @@ def test_hello(self): def test_testcase_totally_incompatible_exception_info(testdir): - item, = testdir.getitems( + (item,) = testdir.getitems( """ from unittest import TestCase class MyTestCase(TestCase):