Skip to content

Commit c1993e6

Browse files
authored
[tests] remove deprecated tests for model loading (#29450)
* gix * fix style * remove equivalent tests * add back for image_processor * remove again
1 parent 0e4a1c3 commit c1993e6

File tree

6 files changed

+0
-62
lines changed

6 files changed

+0
-62
lines changed

tests/test_configuration_utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,6 @@ def test_cached_files_are_used_when_internet_is_down(self):
248248
# This check we did call the fake head request
249249
mock_head.assert_called()
250250

251-
def test_legacy_load_from_url(self):
252-
# This test is for deprecated behavior and can be removed in v5
253-
_ = BertConfig.from_pretrained(
254-
"https://huggingface.co/hf-internal-testing/tiny-random-bert/resolve/main/config.json"
255-
)
256-
257251
def test_local_versioning(self):
258252
configuration = AutoConfig.from_pretrained("google-bert/bert-base-cased")
259253
configuration.configuration_files = ["config.4.0.0.json"]

tests/test_feature_extraction_utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ def test_cached_files_are_used_when_internet_is_down(self):
5252
# This check we did call the fake head request
5353
mock_head.assert_called()
5454

55-
def test_legacy_load_from_url(self):
56-
# This test is for deprecated behavior and can be removed in v5
57-
_ = Wav2Vec2FeatureExtractor.from_pretrained(
58-
"https://huggingface.co/hf-internal-testing/tiny-random-wav2vec2/resolve/main/preprocessor_config.json"
59-
)
60-
6155

6256
@is_staging_test
6357
class FeatureExtractorPushToHubTester(unittest.TestCase):

tests/test_image_processing_utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ def test_cached_files_are_used_when_internet_is_down(self):
5151
# This check we did call the fake head request
5252
mock_head.assert_called()
5353

54-
def test_legacy_load_from_url(self):
55-
# This test is for deprecated behavior and can be removed in v5
56-
_ = ViTImageProcessor.from_pretrained(
57-
"https://huggingface.co/hf-internal-testing/tiny-random-vit/resolve/main/preprocessor_config.json"
58-
)
59-
6054
def test_image_processor_from_pretrained_subfolder(self):
6155
with self.assertRaises(OSError):
6256
# config is in subfolder, the following should not work without specifying the subfolder

tests/test_modeling_tf_utils.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import unittest.mock as mock
2626

2727
from huggingface_hub import HfFolder, Repository, delete_repo, snapshot_download
28-
from huggingface_hub.file_download import http_get
2928
from requests.exceptions import HTTPError
3029

3130
from transformers import is_tf_available, is_torch_available
@@ -106,24 +105,6 @@ def test_cached_files_are_used_when_internet_is_down(self):
106105
# This check we did call the fake head request
107106
mock_head.assert_called()
108107

109-
def test_load_from_one_file(self):
110-
try:
111-
tmp_file = tempfile.mktemp()
112-
with open(tmp_file, "wb") as f:
113-
http_get("https://huggingface.co/hf-internal-testing/tiny-random-bert/resolve/main/tf_model.h5", f)
114-
115-
config = BertConfig.from_pretrained("hf-internal-testing/tiny-random-bert")
116-
_ = TFBertModel.from_pretrained(tmp_file, config=config)
117-
finally:
118-
os.remove(tmp_file)
119-
120-
def test_legacy_load_from_url(self):
121-
# This test is for deprecated behavior and can be removed in v5
122-
config = BertConfig.from_pretrained("hf-internal-testing/tiny-random-bert")
123-
_ = TFBertModel.from_pretrained(
124-
"https://huggingface.co/hf-internal-testing/tiny-random-bert/resolve/main/tf_model.h5", config=config
125-
)
126-
127108
# tests whether the unpack_inputs function behaves as expected
128109
def test_unpack_inputs(self):
129110
class DummyModel:

tests/test_modeling_utils.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import requests
2929
from huggingface_hub import HfApi, HfFolder, delete_repo
30-
from huggingface_hub.file_download import http_get
3130
from pytest import mark
3231
from requests.exceptions import HTTPError
3332

@@ -879,26 +878,6 @@ def test_cached_files_are_used_when_internet_is_down(self):
879878
# This check we did call the fake head request
880879
mock_head.assert_called()
881880

882-
def test_load_from_one_file(self):
883-
try:
884-
tmp_file = tempfile.mktemp()
885-
with open(tmp_file, "wb") as f:
886-
http_get(
887-
"https://huggingface.co/hf-internal-testing/tiny-random-bert/resolve/main/pytorch_model.bin", f
888-
)
889-
890-
config = BertConfig.from_pretrained("hf-internal-testing/tiny-random-bert")
891-
_ = BertModel.from_pretrained(tmp_file, config=config)
892-
finally:
893-
os.remove(tmp_file)
894-
895-
def test_legacy_load_from_url(self):
896-
# This test is for deprecated behavior and can be removed in v5
897-
config = BertConfig.from_pretrained("hf-internal-testing/tiny-random-bert")
898-
_ = BertModel.from_pretrained(
899-
"https://huggingface.co/hf-internal-testing/tiny-random-bert/resolve/main/pytorch_model.bin", config=config
900-
)
901-
902881
@require_safetensors
903882
def test_use_safetensors(self):
904883
# Should not raise anymore

tests/test_tokenization_utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ def test_legacy_load_from_one_file(self):
108108
finally:
109109
os.remove("tokenizer.json")
110110

111-
def test_legacy_load_from_url(self):
112-
# This test is for deprecated behavior and can be removed in v5
113-
_ = AlbertTokenizer.from_pretrained("https://huggingface.co/albert/albert-base-v1/resolve/main/spiece.model")
114-
115111

116112
@is_staging_test
117113
class TokenizerPushToHubTester(unittest.TestCase):

0 commit comments

Comments
 (0)