@@ -81,22 +81,22 @@ def test_Resource__local_update_IncompatibleKeys():
8181 r = Resource (mock .MagicMock ())
8282 with pytest .raises (DeviceProvidesIncompatibleKey ) as DPIKIO :
8383 r ._local_update ({"_meta_data" : "foo" })
84- assert DPIKIO .value . message == \
84+ assert str ( DPIKIO .value ) == \
8585 "Response contains key '_meta_data' which is incompatible" \
8686 " with this API!!\n Response json: {'_meta_data': 'foo'}"
8787 with pytest .raises (DeviceProvidesIncompatibleKey ) as DPIKIO :
8888 r ._local_update ({"__MANGLENAME" : "foo" })
89- assert DPIKIO .value . message == \
89+ assert str ( DPIKIO .value ) == \
9090 "Device provided '__MANGLENAME' which is disallowed," \
9191 " it mangles into a Python non-public attribute."
9292 with pytest .raises (DeviceProvidesIncompatibleKey ) as DPIKIO :
9393 r ._local_update ({"for" : "foo" })
94- assert DPIKIO .value . message == \
94+ assert str ( DPIKIO .value ) == \
9595 "Device provided 'for' which is disallowed because" \
9696 " it's a Python keyword."
9797 with pytest .raises (DeviceProvidesIncompatibleKey ) as DPIKIO :
9898 r ._local_update ({"%abcd" : "foo" })
99- assert DPIKIO .value . message == \
99+ assert str ( DPIKIO .value ) == \
100100 "Device provided '%abcd' which is disallowed because" \
101101 " it's not a valid Python 2.7 identifier."
102102
@@ -132,19 +132,26 @@ def test_missing_required_creation_parameter(self):
132132 r ._meta_data ['required_creation_parameters' ] = set (['NONEMPTY' ])
133133 with pytest .raises (MissingRequiredCreationParameter ) as MRCPEIO :
134134 r .create (partition = "Common" , name = 'CreateTest' )
135- assert MRCPEIO .value . message == \
135+ assert str ( MRCPEIO .value ) == \
136136 "Missing required params: ['NONEMPTY']"
137137
138138 def test_KindTypeMismatch (self ):
139+ expected_result = (
140+ "For instances of type ''Virtual'' the "
141+ "corresponding kind must be ''tm:ltm:virtual:virtualstate'' "
142+ "but creation returned "
143+ "JSON with kind: 'tm:'"
144+ )
139145 r = Virtual (mock .MagicMock ())
146+
140147 r ._meta_data ['bigip' ]._meta_data ['icr_session' ].post .return_value = \
141- MockResponse ({u"kind" : u"tm:" })
142- with pytest .raises (KindTypeMismatch ) as KTMmEIO :
148+ MockResponse ({"kind" : "tm:" })
149+
150+ with pytest .raises (KindTypeMismatch ) as error :
143151 r .create (partition = "Common" , name = "test_create" )
144- assert KTMmEIO .value .message == \
145- "For instances of type ''Virtual'' the corresponding kind must " \
146- "be ''tm:ltm:virtual:virtualstate'' but creation returned " \
147- "JSON with kind: u'tm:'"
152+
153+ result = error .value .args [0 ]
154+ assert result == expected_result
148155
149156 def test_success (self , fake_vs ):
150157 x = fake_vs .create (partition = "Common" , name = "test_create" )
@@ -217,7 +224,7 @@ def test__create_with_Collision():
217224 r ._meta_data ['uri' ] = 'URI'
218225 with pytest .raises (URICreationCollision ) as UCCEIO :
219226 r .create (uri = 'URI' )
220- assert UCCEIO .value . message == \
227+ assert str ( UCCEIO .value ) == \
221228 "There was an attempt to assign a new uri to this resource," \
222229 " the _meta_data['uri'] is URI and it should not be changed."
223230
@@ -235,7 +242,7 @@ def test__check_generation_with_mismatch(self):
235242 r .generation = 1
236243 with pytest .raises (GenerationMismatch ) as GMEIO :
237244 r .update (a = u"b" , force = False )
238- assert GMEIO .value . message == \
245+ assert str ( GMEIO .value ) == \
239246 'The generation of the object on the BigIP (0)' \
240247 ' does not match the current object(1)'
241248
@@ -267,7 +274,6 @@ def test_Collection_removal(self):
267274 r .update (a = u"b" )
268275 submitted = r ._meta_data ['bigip' ]. \
269276 _meta_data ['icr_session' ].put .call_args [1 ]['json' ]
270-
271277 assert 'contained' not in submitted
272278
273279 def test_read_only_removal (self ):
@@ -366,7 +372,7 @@ def test_read_only_validate(self):
366372 r .generation = 0
367373 with pytest .raises (AttemptedMutationOfReadOnly ) as AMOROEIO :
368374 r .modify (READONLY = True )
369- assert "READONLY" in AMOROEIO .value . message
375+ assert "READONLY" in str ( AMOROEIO .value )
370376
371377 def test_reduce_boolean_removes_enabled (self , fake_rsrc ):
372378 fake_rsrc .modify (enabled = False )
@@ -425,7 +431,7 @@ def test_invalid_force(self):
425431 r ._meta_data ['bigip' ]._meta_data = {'icr_session' : mock_session }
426432 with pytest .raises (InvalidForceType ) as IFTEIO :
427433 r .delete (force = 'true' )
428- assert IFTEIO .value . message == 'force parameter must be type bool'
434+ assert str ( IFTEIO .value ) == 'force parameter must be type bool'
429435
430436
431437class Element (Resource ):
@@ -469,7 +475,7 @@ def test_unregistered_kind(self):
469475 c .generation = 0
470476 with pytest .raises (UnregisteredKind ) as UKEIO :
471477 c .get_collection ()
472- assert UKEIO .value . message == \
478+ assert str ( UKEIO .value ) == \
473479 "'tm:' is not registered!"
474480
475481
@@ -479,15 +485,15 @@ def test_missing_required_params(self):
479485 r ._meta_data ['required_load_parameters' ] = set (['IMPOSSIBLE' ])
480486 with pytest .raises (MissingRequiredReadParameter ) as MRREIO :
481487 r .load (partition = 'Common' , name = 'test_load' )
482- assert MRREIO .value . message == \
488+ assert str ( MRREIO .value ) == \
483489 "Missing required params: ['IMPOSSIBLE']"
484490
485491 def test_requests_params_collision (self ):
486492 r = Resource (mock .MagicMock ())
487493 with pytest .raises (RequestParamKwargCollision ) as RPKCEIO :
488494 r .load (partition = 'Common' , name = 'test_load' ,
489495 requests_params = {'partition' : 'ERROR' })
490- assert RPKCEIO .value . message == \
496+ assert str ( RPKCEIO .value ) == \
491497 "Requests Parameter 'partition' collides with a load parameter" \
492498 " of the same name."
493499
0 commit comments