Skip to content

Commit 3f39b43

Browse files
authored
Fixes pycodestyle checks (#1424)
Issues: Fixes #1423 Problem: Code checks were being suppressed Analysis: This fixes the offending checks Tests:
1 parent 2e7d5c7 commit 3f39b43

7 files changed

Lines changed: 101 additions & 106 deletions

File tree

f5/bigip/resource.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ def _check_generation(self):
288288
response = session.get(self._meta_data['uri'])
289289
current_gen = response.json().get('generation', None)
290290
if current_gen is not None and current_gen != self.generation:
291-
error_message = ("The generation of the object on the BigIP " +
292-
"(" + str(current_gen) + ")" +
293-
" does not match the current object" +
294-
"(" + str(self.generation) + ")")
291+
error_message = ("The generation of the object on the BigIP "
292+
+ "(" + str(current_gen) + ")"
293+
+ " does not match the current object"
294+
+ "(" + str(self.generation) + ")")
295295
raise GenerationMismatch(error_message)
296296

297297
def _handle_requests_params(self, kwargs):
@@ -974,7 +974,7 @@ def _create(self, **kwargs):
974974
return result
975975

976976
def create(self, **kwargs):
977-
"""Create the resource on the BIG-IP®.
977+
r"""Create the resource on the BIG-IP®.
978978
979979
Uses HTTP POST to the `collection` URI to create a resource associated
980980
with a new unique URI on the device.
@@ -1041,7 +1041,7 @@ def _load(self, **kwargs):
10411041
return self._produce_instance(response)
10421042

10431043
def load(self, **kwargs):
1044-
"""Load an already configured service into this instance.
1044+
r"""Load an already configured service into this instance.
10451045
10461046
This method uses HTTP GET to obtain a resource from the BIG-IP®.
10471047
@@ -1081,7 +1081,7 @@ def _delete(self, **kwargs):
10811081
self.__dict__ = {'deleted': True}
10821082

10831083
def delete(self, **kwargs):
1084-
"""Delete the resource on the BIG-IP®.
1084+
r"""Delete the resource on the BIG-IP®.
10851085
10861086
Uses HTTP DELETE to delete the resource on the BIG-IP®.
10871087
@@ -1103,7 +1103,7 @@ def delete(self, **kwargs):
11031103
# Need to implement correct teardown here.
11041104

11051105
def exists(self, **kwargs):
1106-
"""Check for the existence of the named object on the BIG-IP
1106+
r"""Check for the existence of the named object on the BIG-IP
11071107
11081108
Sends an HTTP GET to the URI of the named object and if it fails with
11091109
a :exc:~requests.HTTPError` exception it checks the exception for
@@ -1252,7 +1252,7 @@ def _load(self, **kwargs):
12521252
return self._produce_instance(response)
12531253

12541254
def load(self, **kwargs):
1255-
"""Load an already configured service into this instance.
1255+
r"""Load an already configured service into this instance.
12561256
12571257
This method uses HTTP GET to obtain a resource from the BIG-IP®.
12581258
@@ -1303,7 +1303,7 @@ def delete(self, **kwargs):
13031303
# Need to implement correct teardown here.
13041304

13051305
def exists(self, **kwargs):
1306-
"""Check for the existence of the ASM object on the BIG-IP
1306+
r"""Check for the existence of the ASM object on the BIG-IP
13071307
13081308
Sends an HTTP GET to the URI of the ASM object and if it fails with
13091309
a :exc:~requests.HTTPError` exception it checks the exception for
@@ -1504,7 +1504,7 @@ def delete(self, **kwargs):
15041504
# Need to implement correct teardown here.
15051505

15061506
def exists(self, **kwargs):
1507-
"""Check for the existence of the Task object on the BIG-IP
1507+
r"""Check for the existence of the Task object on the BIG-IP
15081508
15091509
Sends an HTTP GET to the URI of the ASM object and if it fails with
15101510
a :exc:~requests.HTTPError` exception it checks the exception for

f5/bigip/tm/gtm/test/functional/test_server.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ def test_load_no_object(self, mgmt_root):
175175
name='fake_serv1')
176176
assert err.value.response.status_code == 404
177177

178-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) ==
179-
'11.5.4',
180-
reason='Needs > v11.5.4 TMOS to pass')
178+
@pytest.mark.skipif(
179+
LooseVersion(pytest.config.getoption('--release')) == '11.5.4',
180+
reason='Needs > v11.5.4 TMOS to pass'
181+
)
181182
def test_load(self, request, mgmt_root):
182183
setup_basic_test(request, mgmt_root, 'fake_serv1', 'Common')
183184
s1 = mgmt_root.tm.gtm.servers.server.load(name='fake_serv1')
@@ -191,9 +192,9 @@ def test_load(self, request, mgmt_root):
191192
assert s2.disabled is True
192193

193194
@pytest.mark.skipif(
194-
LooseVersion(pytest.config.getoption('--release')) >= LooseVersion(
195-
'11.6.0'),
196-
reason='This test is for 11.5.4 or less.')
195+
LooseVersion(pytest.config.getoption('--release')) >= LooseVersion('11.6.0'),
196+
reason='This test is for 11.5.4 or less.'
197+
)
197198
def test_load_11_5_4_and_less(self, request, mgmt_root):
198199
setup_basic_test(request, mgmt_root, 'fake_serv1', 'Common')
199200
s1 = mgmt_root.tm.gtm.servers.server.load(name='fake_serv1')
@@ -236,8 +237,7 @@ def test_delete(self, request, mgmt_root):
236237
class TestServerCollection(object):
237238
def test_server_collection(self, request, mgmt_root):
238239
s1 = setup_basic_test(request, mgmt_root, 'fake_serv1', 'Common')
239-
if LooseVersion(pytest.config.getoption('--release')) >= \
240-
LooseVersion('12.1.0'):
240+
if LooseVersion(pytest.config.getoption('--release')) >= LooseVersion('12.1.0'):
241241
link = 'https://localhost/mgmt/tm/gtm/server/~Common~fake_serv1'
242242
else:
243243
link = 'https://localhost/mgmt/tm/gtm/server/fake_serv1'
@@ -258,8 +258,7 @@ def test_create_req_arg(self, request, mgmt_root):
258258
s1 = setup_basic_test(request, mgmt_root, 'fake_serv1', 'Common')
259259
vs = s1.virtual_servers_s
260260
vs1 = vs.virtual_server.create(name='vs1', destination='5.5.5.5:80')
261-
if LooseVersion(pytest.config.getoption('--release')) >= \
262-
LooseVersion('12.1.0'):
261+
if LooseVersion(pytest.config.getoption('--release')) >= LooseVersion('12.1.0'):
263262
link = 'https://localhost/mgmt/tm/gtm/server/~Common~fake_serv1' \
264263
'/virtual-servers/vs'
265264
else:
@@ -364,9 +363,10 @@ def test_modify(self, request, mgmt_root):
364363
elif k == limit:
365364
assert vs1.__dict__[k] == 'enabled'
366365

367-
@pytest.mark.skipif(pytest.config.getoption('--release') == '11.6.0',
368-
reason='Due to a bug in 11.6.0 Final this test '
369-
'fails')
366+
@pytest.mark.skipif(
367+
pytest.config.getoption('--release') == '11.6.0',
368+
reason='Due to a bug in 11.6.0 Final this test fails'
369+
)
370370
def test_delete(self, request, mgmt_root):
371371
vs1 = setup_vs_basic_test(request, mgmt_root, 'vs2', '5.5.5.5:80')
372372
vs1.delete()
@@ -378,8 +378,7 @@ def test_delete(self, request, mgmt_root):
378378

379379
def test_virtual_server_collection(self, request, mgmt_root):
380380
vs1 = setup_vs_basic_test(request, mgmt_root, 'vs1', '5.5.5.5:80')
381-
if LooseVersion(pytest.config.getoption('--release')) >= \
382-
LooseVersion('12.1.0'):
381+
if LooseVersion(pytest.config.getoption('--release')) >= LooseVersion('12.1.0'):
383382
link = 'https://localhost/mgmt/tm/gtm/server/~Common~fake_serv1' \
384383
'/virtual-servers/vs'
385384
else:

f5/bigip/tm/gtm/test/functional/test_topology.py

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
from pytest import symbols
2525
from requests.exceptions import HTTPError
2626

27+
RELEASE_LOOSE_VERSION = LooseVersion(pytest.config.getoption('--release'))
28+
2729
pytestmark = pytest.mark.skipif(
2830
symbols
2931
and hasattr(symbols, 'modules')
@@ -64,10 +66,10 @@ def teardown():
6466
return top1
6567

6668

67-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) <
68-
'12.1.0' or
69-
LooseVersion(pytest.config.getoption('--release')) ==
70-
'12.0.0', reason='Needs > v12.1.0 TMOS to pass')
69+
@pytest.mark.skipif(
70+
RELEASE_LOOSE_VERSION < '12.1.0' or RELEASE_LOOSE_VERSION == '12.0.0',
71+
reason='Needs > v12.1.0 TMOS to pass'
72+
)
7173
class TestCreate(object):
7274
def test_create_no_args(self, mgmt_root):
7375
with pytest.raises(MissingRequiredCreationParameter):
@@ -105,10 +107,10 @@ def test_create_duplicate(self, request, mgmt_root):
105107
assert err.value.response.status_code == 409
106108

107109

108-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) >=
109-
'12.1.0' or
110-
LooseVersion(pytest.config.getoption('--release')) ==
111-
'12.0.0', reason='Needs < v12.1.0 TMOS to pass')
110+
@pytest.mark.skipif(
111+
RELEASE_LOOSE_VERSION >= '12.1.0' or RELEASE_LOOSE_VERSION == '12.0.0',
112+
reason='Needs < v12.1.0 TMOS to pass'
113+
)
112114
class TestCreate_pre_12_1_0(object):
113115
def test_create_no_args(self, mgmt_root):
114116
with pytest.raises(MissingRequiredCreationParameter):
@@ -146,18 +148,20 @@ def test_create_duplicate(self, request, mgmt_root):
146148
assert err.value.response.status_code == 409
147149

148150

149-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) ==
150-
'12.0.0', reason='Resource disabled for TMOS 12.0.0')
151+
@pytest.mark.skipif(
152+
RELEASE_LOOSE_VERSION == '12.0.0',
153+
reason='Resource disabled for TMOS 12.0.0'
154+
)
151155
class TestRefresh(object):
152156
def test_refresh_raises(self, mgmt_root):
153157
with pytest.raises(UnsupportedOperation):
154158
mgmt_root.tm.gtm.topology_s.topology.refresh()
155159

156160

157-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) <
158-
'12.1.0' or
159-
LooseVersion(pytest.config.getoption('--release')) ==
160-
'12.0.0', reason='Needs > v12.1.0 TMOS to pass')
161+
@pytest.mark.skipif(
162+
RELEASE_LOOSE_VERSION < '12.1.0' or RELEASE_LOOSE_VERSION == '12.0.0',
163+
reason='Needs > v12.1.0 TMOS to pass'
164+
)
161165
class TestLoad(object):
162166
def test_load_no_object(self, mgmt_root):
163167
with pytest.raises(HTTPError) as err:
@@ -174,10 +178,10 @@ def test_load(self, request, mgmt_root):
174178
assert t1.selfLink == t2.selfLink
175179

176180

177-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) >=
178-
'12.1.0' or
179-
LooseVersion(pytest.config.getoption('--release')) ==
180-
'12.0.0', reason='Needs < v12.1.0 TMOS to pass')
181+
@pytest.mark.skipif(
182+
RELEASE_LOOSE_VERSION >= '12.1.0' or RELEASE_LOOSE_VERSION == '12.0.0',
183+
reason='Needs < v12.1.0 TMOS to pass'
184+
)
181185
class TestLoad_pre_12_1_0(object):
182186
def test_load_no_object(self, mgmt_root):
183187
with pytest.raises(HTTPError) as err:
@@ -194,24 +198,30 @@ def test_load(self, request, mgmt_root):
194198
assert t1.selfLink == t2.selfLink
195199

196200

197-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) ==
198-
'12.0.0', reason='Resource disabled for TMOS 12.0.0')
201+
@pytest.mark.skipif(
202+
RELEASE_LOOSE_VERSION == '12.0.0',
203+
reason='Resource disabled for TMOS 12.0.0'
204+
)
199205
class TestUpdate(object):
200206
def test_update_raises(self, mgmt_root):
201207
with pytest.raises(UnsupportedOperation):
202208
mgmt_root.tm.gtm.topology_s.topology.update()
203209

204210

205-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) ==
206-
'12.0.0', reason='Resource disabled for TMOS 12.0.0')
211+
@pytest.mark.skipif(
212+
RELEASE_LOOSE_VERSION == '12.0.0',
213+
reason='Resource disabled for TMOS 12.0.0'
214+
)
207215
class TestModify(object):
208216
def test_modify_raises(self, mgmt_root):
209217
with pytest.raises(UnsupportedOperation):
210218
mgmt_root.tm.gtm.topology_s.topology.modify()
211219

212220

213-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) <
214-
'12.1.0', reason='Needs > v12.1.0 TMOS to pass')
221+
@pytest.mark.skipif(
222+
RELEASE_LOOSE_VERSION < '12.1.0',
223+
reason='Needs > v12.1.0 TMOS to pass'
224+
)
215225
class TestDelete(object):
216226
def test_delete(self, request, mgmt_root):
217227
r1 = setup_basic_test(request, mgmt_root, NAME)
@@ -221,10 +231,10 @@ def test_delete(self, request, mgmt_root):
221231
assert err.value.response.status_code == 404
222232

223233

224-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) >=
225-
'12.1.0' or
226-
LooseVersion(pytest.config.getoption('--release')) ==
227-
'12.0.0', reason='Needs < v12.1.0 TMOS to pass')
234+
@pytest.mark.skipif(
235+
RELEASE_LOOSE_VERSION >= '12.1.0' or RELEASE_LOOSE_VERSION == '12.0.0',
236+
reason='Needs < v12.1.0 TMOS to pass'
237+
)
228238
class TestDelete_pre_12_1_0(object):
229239
def test_delete(self, request, mgmt_root):
230240
r1 = setup_basic_test(request, mgmt_root, NAME_SPACES)
@@ -234,10 +244,10 @@ def test_delete(self, request, mgmt_root):
234244
assert err.value.response.status_code == 404
235245

236246

237-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) <
238-
'12.1.0' or
239-
LooseVersion(pytest.config.getoption('--release')) ==
240-
'12.0.0', reason='Needs > v12.1.0 TMOS to pass')
247+
@pytest.mark.skipif(
248+
RELEASE_LOOSE_VERSION < '12.1.0' or RELEASE_LOOSE_VERSION == '12.0.0',
249+
reason='Needs > v12.1.0 TMOS to pass'
250+
)
241251
class TestTopologyCollection(object):
242252
def test_region_collection(self, request, mgmt_root):
243253
setup_create_test(request, mgmt_root, NAME)
@@ -257,10 +267,10 @@ def test_region_collection(self, request, mgmt_root):
257267
assert isinstance(rc[0], Topology)
258268

259269

260-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) >=
261-
'12.1.0' or
262-
LooseVersion(pytest.config.getoption('--release')) ==
263-
'12.0.0', reason='Needs < v12.1.0 TMOS to pass')
270+
@pytest.mark.skipif(
271+
RELEASE_LOOSE_VERSION >= '12.1.0' or RELEASE_LOOSE_VERSION == '12.0.0',
272+
reason='Needs < v12.1.0 TMOS to pass'
273+
)
264274
class TestTopologyCollection_pre_12_1_0(object):
265275
def test_region_collection(self, request, mgmt_root):
266276
setup_create_test(request, mgmt_root, NAME_SPACES)
@@ -280,8 +290,10 @@ def test_region_collection(self, request, mgmt_root):
280290
assert isinstance(rc[0], Topology)
281291

282292

283-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) !=
284-
'12.0.0', reason='Only TMOS 12.0.0 test')
293+
@pytest.mark.skipif(
294+
RELEASE_LOOSE_VERSION != '12.0.0',
295+
reason='Only TMOS 12.0.0 test'
296+
)
285297
class TestTopology_12_0_0(object):
286298
def test_topology_raises(self, request, mgmt_root):
287299
with pytest.raises(UnsupportedTmosVersion):

f5/bigip/tm/net/test/functional/test_trunk.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323

2424
pytestmark = pytest.mark.skipif(
25-
not symbols or
26-
symbols and not hasattr(symbols, 'run_hardware_tests') or
27-
symbols and hasattr(symbols, 'run_hardware_tests') and symbols.modules['run_hardware_tests'] is False,
25+
not symbols
26+
or symbols and not hasattr(symbols, 'run_hardware_tests')
27+
or symbols and hasattr(symbols, 'run_hardware_tests')
28+
and symbols.modules['run_hardware_tests'] is False,
2829
reason='This series of tests requires a hardware BIG-IP be specified.'
2930
)
3031

f5/bigip/tm/sys/performance.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def get_collection(self):
4444
:raises: :exc:`~f5.BIG-IP.resource.UnsupportedOperation`
4545
'''
4646
raise UnsupportedOperation(
47-
"The iControl REST URI mgmt/sys/performance/ does not respond " +
48-
"GET requests."
47+
"The iControl REST URI mgmt/sys/performance/ does not respond GET requests."
4948
)
5049

5150

@@ -62,5 +61,4 @@ def update(self, **kwargs):
6261
6362
:raises: :exc:`~f5.BIG-IP.resource.UnsupportedOperation`
6463
'''
65-
raise UnsupportedOperation(
66-
'Stats do not support create, only load and refresh')
64+
raise UnsupportedOperation('Stats do not support create, only load and refresh')

0 commit comments

Comments
 (0)