@@ -104,28 +104,10 @@ def test_200_error(self):
104104 self .client .country ('1.1.1.1' )
105105
106106 def test_400_error (self ):
107- body = {'code' : 'IP_ADDRESS_INVALID' ,
108- 'error' : 'The value "1.2.3" is not a '
109- 'valid ip address' ,}
110- httpretty .register_uri (httpretty .GET ,
111- self .base_uri + 'country/1.2.3' ,
112- body = json .dumps (body ),
113- status = 400 ,
114- content_type = self ._content_type ('country' ))
115- with self .assertRaisesRegex (WebServiceError ,
116- 'The value "1.2.3" is not a valid '
117- 'ip address' ):
118- self .client .country ('1.2.3' )
119- # XXX - there might be a better way to do this
120- try :
107+ with self .assertRaisesRegex (ValueError ,
108+ "'1.2.3' does not appear to be an IPv4 "
109+ "or IPv6 address" ):
121110 self .client .country ('1.2.3' )
122- except WebServiceError as e :
123- self .assertEqual (e .http_status , 400 ,
124- 'exception object contains expected http_status'
125- )
126- self .assertEqual (e .code ,'IP_ADDRESS_INVALID' ,
127- 'exception object contains expected code'
128- )
129111
130112 def test_no_body_error (self ):
131113 httpretty .register_uri (httpretty .GET ,
0 commit comments