2
2
import itertools
3
3
import tempfile
4
4
import time
5
+ import traceback
5
6
import unittest .mock
6
7
import warnings
7
8
from datetime import datetime
@@ -127,19 +128,23 @@ def add_mock(stack, name, file, **kwargs):
127
128
128
129
129
130
def retry (fn , times = 1 , wait = 5.0 ):
130
- msgs = []
131
+ tbs = []
131
132
for _ in range (times + 1 ):
132
133
try :
133
134
return fn ()
134
135
except AssertionError as error :
135
- msgs .append (str ( error ))
136
+ tbs .append ("" . join ( traceback . format_exception ( type ( error ), error , error . __traceback__ ) ))
136
137
time .sleep (wait )
137
138
else :
138
139
raise AssertionError (
139
140
"\n " .join (
140
141
(
141
- f"Assertion failed { times + 1 } times with { wait :.1f} seconds intermediate wait time.\n " ,
142
- * (f"{ idx } : { error } " for idx , error in enumerate (msgs , 1 )),
142
+ "\n " ,
143
+ * [f"{ '_' * 40 } { idx :2d} { '_' * 40 } \n \n { tb } " for idx , tb in enumerate (tbs , 1 )],
144
+ (
145
+ f"Assertion failed { times + 1 } times with { wait :.1f} seconds intermediate wait time. "
146
+ f"You can find the the full tracebacks above."
147
+ ),
143
148
)
144
149
)
145
150
)
@@ -149,10 +154,12 @@ def retry(fn, times=1, wait=5.0):
149
154
def assert_server_response_ok ():
150
155
try :
151
156
yield
152
- except URLError as error :
153
- raise AssertionError ("The request timed out." ) from error
154
157
except HTTPError as error :
155
158
raise AssertionError (f"The server returned { error .code } : { error .reason } ." ) from error
159
+ except URLError as error :
160
+ raise AssertionError (
161
+ "Connection not possible due to SSL." if "SSL" in str (error ) else "The request timed out."
162
+ ) from error
156
163
except RecursionError as error :
157
164
raise AssertionError (str (error )) from error
158
165
@@ -448,7 +455,6 @@ def make_parametrize_kwargs(download_configs):
448
455
omniglot (),
449
456
phototour (),
450
457
sbdataset (),
451
- sbu (),
452
458
semeion (),
453
459
stl10 (),
454
460
svhn (),
@@ -472,6 +478,7 @@ def test_url_is_accessible(url, md5):
472
478
** make_parametrize_kwargs (
473
479
itertools .chain (
474
480
places365 (), # https://github.com/pytorch/vision/issues/6268
481
+ sbu (), # https://github.com/pytorch/vision/issues/7005
475
482
)
476
483
)
477
484
)
0 commit comments