File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 5
5
import shutil
6
6
import subprocess
7
7
import tempfile
8
+ from urllib .error import HTTPError
8
9
9
10
import torch # noqa: F401
10
11
from torch .testing ._internal .common_utils import TestCase
11
12
12
13
logger = logging .getLogger (__name__ )
13
14
14
15
16
+ def third_party_download (test_func ):
17
+ def inner (* args , ** kwargs ):
18
+ try :
19
+ return test_func (* args , ** kwargs )
20
+ except HTTPError as e :
21
+ logger .warning (f"Cannot access URL in { test_func .__name__ } . Error message { e } " )
22
+
23
+ return inner
24
+
25
+
15
26
class TorchtextTestCase (TestCase ):
16
27
def setUp (self ) -> None :
17
28
logging .basicConfig (format = ("%(asctime)s - %(levelname)s - " "%(name)s - %(message)s" ), level = logging .INFO )
Original file line number Diff line number Diff line change 5
5
import torch
6
6
import torchtext .data
7
7
8
- from .common .torchtext_test_case import TorchtextTestCase
8
+ from .common .torchtext_test_case import TorchtextTestCase , third_party_download
9
9
10
10
11
11
class TestDataUtils (TorchtextTestCase ):
@@ -64,6 +64,7 @@ def test_vectors_get_vecs(self) -> None:
64
64
self .assertEqual (token_one_vec .shape [0 ], vec .dim )
65
65
self .assertEqual (vec [tokens [0 ].lower ()], token_one_vec )
66
66
67
+ @third_party_download
67
68
def test_download_charngram_vectors (self ) -> None :
68
69
# Build a vocab and get vectors twice to test caching.
69
70
for _ in range (2 ):
You can’t perform that action at this time.
0 commit comments