From 169b8cde471ec48e557f4c2d0c8e0d40abb13040 Mon Sep 17 00:00:00 2001 From: Lucain Date: Mon, 29 Aug 2022 15:56:08 +0200 Subject: [PATCH] Fix mock in `test_cached_files_are_used_when_internet_is_down` (#18804) --- tests/test_configuration_common.py | 1 + tests/test_feature_extraction_common.py | 1 + tests/test_modeling_common.py | 1 + tests/test_modeling_tf_common.py | 1 + tests/test_tokenization_common.py | 1 + 5 files changed, 5 insertions(+) diff --git a/tests/test_configuration_common.py b/tests/test_configuration_common.py index 5447fb6afb..a7283b5f31 100644 --- a/tests/test_configuration_common.py +++ b/tests/test_configuration_common.py @@ -349,6 +349,7 @@ class ConfigTestUtils(unittest.TestCase): response_mock.status_code = 500 response_mock.headers = {} response_mock.raise_for_status.side_effect = HTTPError + response_mock.json.return_value = {} # Download this model to make sure it's in the cache. _ = BertConfig.from_pretrained("hf-internal-testing/tiny-random-bert") diff --git a/tests/test_feature_extraction_common.py b/tests/test_feature_extraction_common.py index 3ecf89a908..61bd85e892 100644 --- a/tests/test_feature_extraction_common.py +++ b/tests/test_feature_extraction_common.py @@ -172,6 +172,7 @@ class FeatureExtractorUtilTester(unittest.TestCase): response_mock.status_code = 500 response_mock.headers = {} response_mock.raise_for_status.side_effect = HTTPError + response_mock.json.return_value = {} # Download this model to make sure it's in the cache. _ = Wav2Vec2FeatureExtractor.from_pretrained("hf-internal-testing/tiny-random-wav2vec2") diff --git a/tests/test_modeling_common.py b/tests/test_modeling_common.py index 5a2888a12a..05921334a6 100755 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -2931,6 +2931,7 @@ class ModelUtilsTest(TestCasePlus): response_mock.status_code = 500 response_mock.headers = {} response_mock.raise_for_status.side_effect = HTTPError + response_mock.json.return_value = {} # Download this model to make sure it's in the cache. _ = BertModel.from_pretrained("hf-internal-testing/tiny-random-bert") diff --git a/tests/test_modeling_tf_common.py b/tests/test_modeling_tf_common.py index abf26af2b6..3372e96454 100644 --- a/tests/test_modeling_tf_common.py +++ b/tests/test_modeling_tf_common.py @@ -1924,6 +1924,7 @@ class UtilsFunctionsTest(unittest.TestCase): response_mock.status_code = 500 response_mock.headers = {} response_mock.raise_for_status.side_effect = HTTPError + response_mock.json.return_value = {} # Download this model to make sure it's in the cache. _ = TFBertModel.from_pretrained("hf-internal-testing/tiny-random-bert") diff --git a/tests/test_tokenization_common.py b/tests/test_tokenization_common.py index e1522ba3c6..bdb7b6ce67 100644 --- a/tests/test_tokenization_common.py +++ b/tests/test_tokenization_common.py @@ -3875,6 +3875,7 @@ class TokenizerUtilTester(unittest.TestCase): response_mock.status_code = 500 response_mock.headers = {} response_mock.raise_for_status.side_effect = HTTPError + response_mock.json.return_value = {} # Download this model to make sure it's in the cache. _ = BertTokenizer.from_pretrained("hf-internal-testing/tiny-random-bert")