Skip to content

Commit ac0a62c

Browse files
committed
Move test imports to the top of the file
1 parent 0088066 commit ac0a62c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

keras_hub/src/utils/preset_utils_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from unittest import mock
44

55
import keras
6+
from huggingface_hub.utils import EntryNotFoundError
7+
from kagglehub.exceptions import KaggleApiHTTPError
68
import pytest
79
from absl.testing import parameterized
810

@@ -204,8 +206,6 @@ def test_get_file_raises_file_not_found(self):
204206
get_file(local_dir, fake_path)
205207

206208
def test_kaggle_error_translation(self):
207-
from kagglehub.exceptions import KaggleApiHTTPError
208-
209209
preset = "kaggle://keras/bert/keras/bert_base_en"
210210
# Kaggle serves a missing file as a 404 and a gated file as a 403;
211211
# both translate to FileNotFoundError (check_file_exists relies on
@@ -223,8 +223,6 @@ def test_kaggle_error_translation(self):
223223
get_file(preset, "vocabulary.json")
224224

225225
def test_hf_missing_entry_translation(self):
226-
from huggingface_hub.utils import EntryNotFoundError
227-
228226
error = EntryNotFoundError("404 Client Error")
229227
with mock.patch("huggingface_hub.hf_hub_download", side_effect=error):
230228
with self.assertRaises(FileNotFoundError):

0 commit comments

Comments
 (0)