Skip to content

Commit e2cfb8d

Browse files
Gustrynyalldawson
authored andcommittedJan 31, 2023
Tests - Run pyupgrade on all Python test files
1 parent a953b34 commit e2cfb8d

File tree

458 files changed

+2297
-2829
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

458 files changed

+2297
-2829
lines changed
 

‎.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ exclude =
127127
python/server/auto_additions/,
128128
# Plenty of star imports used
129129
python/PyQt/
130+
cmake/
131+
# People using a virtualenv
132+
.venv/
133+
venv/

‎tests/src/python/test_authmanager_oauth2_ows.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Tests for auth manager WMS/WFS using QGIS Server through OAuth2
43
enabled qgis_wrapped_server.py.
@@ -167,8 +166,8 @@ def setUpClass(cls):
167166
assert cls.port != 0
168167

169168
# We need a valid port before we setup the oauth configuration
170-
cls.token_uri = '%s://%s:%s/token' % (cls.protocol, cls.hostname, cls.port)
171-
cls.refresh_token_uri = '%s://%s:%s/refresh' % (cls.protocol, cls.hostname, cls.port)
169+
cls.token_uri = f'{cls.protocol}://{cls.hostname}:{cls.port}/token'
170+
cls.refresh_token_uri = f'{cls.protocol}://{cls.hostname}:{cls.port}/refresh'
172171
# Need a random authcfg or the cache will bites us back!
173172
cls.authcfg_id = setup_oauth(cls.username, cls.password, cls.token_uri, cls.refresh_token_uri, str(random.randint(0, 10000000)))
174173
# This is to test wrong credentials
@@ -178,7 +177,7 @@ def setUpClass(cls):
178177
assert cls.auth_config.isValid()
179178

180179
# Wait for the server process to start
181-
assert waitServer('%s://%s:%s' % (cls.protocol, cls.hostname, cls.port)), "Server is not responding! %s://%s:%s" % (cls.protocol, cls.hostname, cls.port)
180+
assert waitServer(f'{cls.protocol}://{cls.hostname}:{cls.port}'), f"Server is not responding! {cls.protocol}://{cls.hostname}:{cls.port}"
182181

183182
@classmethod
184183
def tearDownClass(cls):
@@ -205,13 +204,13 @@ def _getWFSLayer(cls, type_name, layer_name=None, authcfg=None):
205204
parms = {
206205
'srsname': 'EPSG:4326',
207206
'typename': type_name,
208-
'url': '%s://%s:%s/?map=%s' % (cls.protocol, cls.hostname, cls.port, cls.project_path),
207+
'url': f'{cls.protocol}://{cls.hostname}:{cls.port}/?map={cls.project_path}',
209208
'version': 'auto',
210209
'table': '',
211210
}
212211
if authcfg is not None:
213212
parms.update({'authcfg': authcfg})
214-
uri = ' '.join([("%s='%s'" % (k, v)) for k, v in list(parms.items())])
213+
uri = ' '.join([(f"{k}='{v}'") for k, v in list(parms.items())])
215214
wfs_layer = QgsVectorLayer(uri, layer_name, 'WFS')
216215
return wfs_layer
217216

@@ -224,7 +223,7 @@ def _getWMSLayer(cls, layers, layer_name=None, authcfg=None):
224223
layer_name = 'wms_' + layers.replace(',', '')
225224
parms = {
226225
'crs': 'EPSG:4326',
227-
'url': '%s://%s:%s/?map=%s' % (cls.protocol, cls.hostname, cls.port, cls.project_path),
226+
'url': f'{cls.protocol}://{cls.hostname}:{cls.port}/?map={cls.project_path}',
228227
'format': 'image/png',
229228
# This is needed because of a really weird implementation in QGIS Server, that
230229
# replaces _ in the the real layer name with spaces
@@ -235,7 +234,7 @@ def _getWMSLayer(cls, layers, layer_name=None, authcfg=None):
235234
}
236235
if authcfg is not None:
237236
parms.update({'authcfg': authcfg})
238-
uri = '&'.join([("%s=%s" % (k, v.replace('=', '%3D'))) for k, v in list(parms.items())])
237+
uri = '&'.join([("{}={}".format(k, v.replace('=', '%3D'))) for k, v in list(parms.items())])
239238
wms_layer = QgsRasterLayer(uri, layer_name, 'wms')
240239
return wms_layer
241240

0 commit comments

Comments
 (0)
Please sign in to comment.