From 1f8e290a7b287c5d8aaafd0ff91692d1343ce1a9 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Sun, 13 Mar 2022 18:23:15 -0500 Subject: pyupgrade --py37-plus --- tests/pkgs/eventonly/__init__.py | 2 +- tests/pkgs/subrequestapp/__init__.py | 2 +- tests/test_authentication.py | 2 +- tests/test_config/test_views.py | 2 +- tests/test_csrf.py | 6 +++--- tests/test_integration.py | 2 +- tests/test_path.py | 22 ++++++++++++++-------- tests/test_response.py | 2 +- tests/test_scripts/test_proutes.py | 2 +- tests/test_session.py | 4 ++-- tests/test_static.py | 2 +- tests/test_traversal.py | 2 +- tests/test_viewderivers.py | 2 +- 13 files changed, 29 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/pkgs/eventonly/__init__.py b/tests/pkgs/eventonly/__init__.py index d0d4dafb9..e45a5691f 100644 --- a/tests/pkgs/eventonly/__init__.py +++ b/tests/pkgs/eventonly/__init__.py @@ -7,7 +7,7 @@ class Yup: self.val = val def text(self): - return 'path_startswith = %s' % (self.val,) + return f'path_startswith = {self.val}' phash = text diff --git a/tests/pkgs/subrequestapp/__init__.py b/tests/pkgs/subrequestapp/__init__.py index 177f5637b..9c0d0daa1 100644 --- a/tests/pkgs/subrequestapp/__init__.py +++ b/tests/pkgs/subrequestapp/__init__.py @@ -10,7 +10,7 @@ def view_one(request): def view_two(request): # check that request.foo is valid for a subrequest - return 'This came from view_two, foo=%s' % (request.foo,) + return f'This came from view_two, foo={request.foo}' def view_three(request): diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 5f46e4cd1..a950774c5 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -1946,7 +1946,7 @@ class DummyAuthTktModule: if isinstance(v, bytes): v = text_(v) new_items.append((k, v)) - result = '/'.join(['%s=%s' % (k, v) for k, v in new_items]) + result = '/'.join([f'{k}={v}' for k, v in new_items]) return result self.AuthTicket = AuthTicket diff --git a/tests/test_config/test_views.py b/tests/test_config/test_views.py index 72f8f0145..c7d8c2721 100644 --- a/tests/test_config/test_views.py +++ b/tests/test_config/test_views.py @@ -4399,7 +4399,7 @@ def assert_similar_datetime(one, two): one_attr = getattr(one, attr) two_attr = getattr(two, attr) if not one_attr == two_attr: # pragma: no cover - raise AssertionError('%r != %r in %s' % (one_attr, two_attr, attr)) + raise AssertionError(f'{one_attr!r} != {two_attr!r} in {attr}') class DummyStaticURLInfo: diff --git a/tests/test_csrf.py b/tests/test_csrf.py index 191b0864f..dc1f97829 100644 --- a/tests/test_csrf.py +++ b/tests/test_csrf.py @@ -128,7 +128,7 @@ class TestCookieCSRFStoragePolicy(unittest.TestCase): [ ( 'Set-Cookie', - 'csrf_token={}; Path=/; SameSite=Lax'.format(token), + f'csrf_token={token}; Path=/; SameSite=Lax', ) ], ) @@ -142,7 +142,7 @@ class TestCookieCSRFStoragePolicy(unittest.TestCase): request.response_callback(request, response) self.assertEqual( response.headerlist, - [('Set-Cookie', 'csrf_token={}; Path=/'.format(token))], + [('Set-Cookie', f'csrf_token={token}; Path=/')], ) def test_existing_cookie_csrf_does_not_set_cookie(self): @@ -169,7 +169,7 @@ class TestCookieCSRFStoragePolicy(unittest.TestCase): [ ( 'Set-Cookie', - 'csrf_token={}; Path=/; SameSite=Lax'.format(token), + f'csrf_token={token}; Path=/; SameSite=Lax', ) ], ) diff --git a/tests/test_integration.py b/tests/test_integration.py index f671b7c0b..0b55872d2 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -447,7 +447,7 @@ class TestForbiddenAppHasResult(IntegrationBase, unittest.TestCase): def test_it(self): res = self.testapp.get('/x', status=403) - message, result = [x.strip() for x in res.body.split(b'\n')] + message, result = (x.strip() for x in res.body.split(b'\n')) self.assertTrue(message.endswith(b'failed permission check')) self.assertTrue( result.startswith( diff --git a/tests/test_path.py b/tests/test_path.py index 479e12e40..6f12303f7 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -339,27 +339,33 @@ class TestPkgResourcesAssetDescriptor(unittest.TestCase): def test_stream(self): inst = self._makeOne() inst.pkg_resources = DummyPkgResource() - inst.pkg_resources.resource_stream = lambda x, y: '%s:%s' % (x, y) + inst.pkg_resources.resource_stream = lambda x, y: f'{x}:{y}' s = inst.stream() - self.assertEqual(s, '%s:%s' % ('tests', 'test_asset.py')) + self.assertEqual(s, '{}:{}'.format('tests', 'test_asset.py')) def test_isdir(self): inst = self._makeOne() inst.pkg_resources = DummyPkgResource() - inst.pkg_resources.resource_isdir = lambda x, y: '%s:%s' % (x, y) - self.assertEqual(inst.isdir(), '%s:%s' % ('tests', 'test_asset.py')) + inst.pkg_resources.resource_isdir = lambda x, y: f'{x}:{y}' + self.assertEqual( + inst.isdir(), '{}:{}'.format('tests', 'test_asset.py') + ) def test_listdir(self): inst = self._makeOne() inst.pkg_resources = DummyPkgResource() - inst.pkg_resources.resource_listdir = lambda x, y: '%s:%s' % (x, y) - self.assertEqual(inst.listdir(), '%s:%s' % ('tests', 'test_asset.py')) + inst.pkg_resources.resource_listdir = lambda x, y: f'{x}:{y}' + self.assertEqual( + inst.listdir(), '{}:{}'.format('tests', 'test_asset.py') + ) def test_exists(self): inst = self._makeOne() inst.pkg_resources = DummyPkgResource() - inst.pkg_resources.resource_exists = lambda x, y: '%s:%s' % (x, y) - self.assertEqual(inst.exists(), '%s:%s' % ('tests', 'test_asset.py')) + inst.pkg_resources.resource_exists = lambda x, y: f'{x}:{y}' + self.assertEqual( + inst.exists(), '{}:{}'.format('tests', 'test_asset.py') + ) class TestFSAssetDescriptor(unittest.TestCase): diff --git a/tests/test_response.py b/tests/test_response.py index abfbbc4f1..63def1212 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -33,7 +33,7 @@ class TestFileResponse(unittest.TestCase): def _getPath(self, suffix='txt'): here = os.path.dirname(__file__) - return os.path.join(here, 'fixtures', 'minimal.%s' % (suffix,)) + return os.path.join(here, 'fixtures', f'minimal.{suffix}') def test_with_image_content_type(self): path = self._getPath('jpg') diff --git a/tests/test_scripts/test_proutes.py b/tests/test_scripts/test_proutes.py index 8ac5d0fd1..c0aeb01d3 100644 --- a/tests/test_scripts/test_proutes.py +++ b/tests/test_scripts/test_proutes.py @@ -320,7 +320,7 @@ class TestPRoutesCommand(unittest.TestCase): compare_to = L[-1].split()[:3] view_module = 'tests.test_scripts.dummy' view_str = '' % ( + return ''.format( self.__name__, id(self), ) diff --git a/tests/test_viewderivers.py b/tests/test_viewderivers.py index bec016461..9baa97c4c 100644 --- a/tests/test_viewderivers.py +++ b/tests/test_viewderivers.py @@ -2106,4 +2106,4 @@ def assert_similar_datetime(one, two): one_attr = getattr(one, attr) two_attr = getattr(two, attr) if not one_attr == two_attr: # pragma: no cover - raise AssertionError('%r != %r in %s' % (one_attr, two_attr, attr)) + raise AssertionError(f'{one_attr!r} != {two_attr!r} in {attr}') -- cgit v1.2.3