diff options
| author | Michael Merickel <michael@merickel.org> | 2022-03-13 18:23:15 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2022-03-13 18:24:26 -0500 |
| commit | 1f8e290a7b287c5d8aaafd0ff91692d1343ce1a9 (patch) | |
| tree | f490995d5bf34627b9753b35eb2b7767ae68c3dc /tests | |
| parent | 1e439035e41da3767acbcae79689fb05dfdeb317 (diff) | |
| download | pyramid-1f8e290a7b287c5d8aaafd0ff91692d1343ce1a9.tar.gz pyramid-1f8e290a7b287c5d8aaafd0ff91692d1343ce1a9.tar.bz2 pyramid-1f8e290a7b287c5d8aaafd0ff91692d1343ce1a9.zip | |
pyupgrade --py37-plus
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/pkgs/eventonly/__init__.py | 2 | ||||
| -rw-r--r-- | tests/pkgs/subrequestapp/__init__.py | 2 | ||||
| -rw-r--r-- | tests/test_authentication.py | 2 | ||||
| -rw-r--r-- | tests/test_config/test_views.py | 2 | ||||
| -rw-r--r-- | tests/test_csrf.py | 6 | ||||
| -rw-r--r-- | tests/test_integration.py | 2 | ||||
| -rw-r--r-- | tests/test_path.py | 22 | ||||
| -rw-r--r-- | tests/test_response.py | 2 | ||||
| -rw-r--r-- | tests/test_scripts/test_proutes.py | 2 | ||||
| -rw-r--r-- | tests/test_session.py | 4 | ||||
| -rw-r--r-- | tests/test_static.py | 2 | ||||
| -rw-r--r-- | tests/test_traversal.py | 2 | ||||
| -rw-r--r-- | tests/test_viewderivers.py | 2 |
13 files changed, 29 insertions, 23 deletions
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 = '<tests.test_scripts.dummy.DummyMultiView' - final = '%s.%s' % (view_module, view_str) + final = f'{view_module}.{view_str}' self.assertEqual(compare_to, ['a', '/a', final]) diff --git a/tests/test_session.py b/tests/test_session.py index b86abe191..f0c0540e5 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -160,9 +160,9 @@ class SharedCookieSessionTests: response = Response() self.assertEqual(session._set_cookie(response), True) cookieval = response.headerlist[-1][1] - val, domain, path, secure, httponly, samesite = [ + val, domain, path, secure, httponly, samesite = ( x.strip() for x in cookieval.split(';') - ] + ) self.assertTrue(val.startswith('abc=')) self.assertEqual(domain, 'Domain=localhost') self.assertEqual(path, 'Path=/foo') diff --git a/tests/test_static.py b/tests/test_static.py index 3fc6586e9..af487fa24 100644 --- a/tests/test_static.py +++ b/tests/test_static.py @@ -97,7 +97,7 @@ class Test_static_view_use_subpath_False(unittest.TestCase): inst = self._makeOne('tests:fixtures/static') dds = '..' + os.sep request = self._makeRequest( - {'PATH_INFO': '/subdir/%s%sminimal.pt' % (dds, dds)} + {'PATH_INFO': f'/subdir/{dds}{dds}minimal.pt'} ) context = DummyContext() from pyramid.httpexceptions import HTTPNotFound diff --git a/tests/test_traversal.py b/tests/test_traversal.py index a8b81c48b..0d8096f15 100644 --- a/tests/test_traversal.py +++ b/tests/test_traversal.py @@ -1264,7 +1264,7 @@ class DummyContext: return self.next def __repr__(self): - return '<DummyContext with name %s at id %s>' % ( + return '<DummyContext with name {} at id {}>'.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}') |
