File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
#-*- coding:utf-8 -*-
3
3
4
+ import socket
5
+
4
6
from nose .tools import assert_raises
5
- from urllib2 import URLError
6
7
from mox import Mox
7
8
8
9
import bitly
@@ -109,7 +110,7 @@ def verifying_that_a_custom_exception_is_raised_on_timeout(api):
109
110
bitly_shortening_url = 'http://api.bit.ly/shorten?login=jcfigueiredo&version=2.0.1&apiKey=R_1cf5dc0fa14c2df34261fb620bd256aa&format=json&longUrl=http%3A%2F%2Fwww.matandorobosgigantes.com'
110
111
111
112
mox .StubOutWithMock (httplib2 .Http , "request" )
112
- httplib2 .Http .request (bitly_shortening_url ).AndRaise (URLError ( 'urlopen error timed out' ))
113
+ httplib2 .Http .request (bitly_shortening_url ).AndRaise (socket . timeout ( ' timed out' ))
113
114
114
115
url_to_be_shortened = 'http://www.matandorobosgigantes.com'
115
116
@@ -126,13 +127,13 @@ def verifying_that_urlerror_exceptions_are_reraised_but_timeout_exceptions(api):
126
127
bitly_shortening_url = 'http://api.bit.ly/shorten?login=jcfigueiredo&version=2.0.1&apiKey=R_1cf5dc0fa14c2df34261fb620bd256aa&format=json&longUrl=http%3A%2F%2Fwww.matandorobosgigantes.com'
127
128
128
129
mox .StubOutWithMock (httplib2 .Http , "request" )
129
- httplib2 .Http .request (bitly_shortening_url ).AndRaise (URLError ('something different from timeout' ))
130
+ httplib2 .Http .request (bitly_shortening_url ).AndRaise (socket . timeout ('something different from timeout' ))
130
131
131
132
url_to_be_shortened = 'http://www.matandorobosgigantes.com'
132
133
133
134
try :
134
135
mox .ReplayAll ()
135
- assert_raises (URLError , api .shorten , url_to_be_shortened )
136
+ assert_raises (socket . timeout , api .shorten , url_to_be_shortened )
136
137
mox .VerifyAll ()
137
138
finally :
138
139
mox .UnsetStubs ()
You can’t perform that action at this time.
0 commit comments