2424from pytest import symbols
2525from requests .exceptions import HTTPError
2626
27+ RELEASE_LOOSE_VERSION = LooseVersion (pytest .config .getoption ('--release' ))
28+
2729pytestmark = 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+ )
7173class 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+ )
112114class 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+ )
151155class 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+ )
161165class 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+ )
181185class 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+ )
199205class 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+ )
207215class 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+ )
215225class 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+ )
228238class 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+ )
241251class 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+ )
264274class 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+ )
285297class TestTopology_12_0_0 (object ):
286298 def test_topology_raises (self , request , mgmt_root ):
287299 with pytest .raises (UnsupportedTmosVersion ):
0 commit comments