Skip to content

Commit 9350f48

Browse files
committed
fix test to mock backend selection path
Patch the AutoImageProcessor fallback regression test to mock the backend resolution helper used by image_processing_auto, so it correctly simulates a no-torchvision environment in CI. Made-with: Cursor
1 parent 11edb18 commit 9350f48

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

tests/models/auto/test_image_processing_auto.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
ViTImageProcessorPil,
3333
)
3434
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_torchvision, require_vision
35-
from transformers.utils.import_utils import BACKENDS_MAPPING
3635

3736

3837
sys.path.append(str(Path(__file__).parent.parent.parent.parent / "utils"))
@@ -291,8 +290,7 @@ def test_auto_backend_falls_back_to_pil_when_torchvision_is_unavailable(self):
291290
processor_tmpfile = Path(tmpdirname) / "preprocessor_config.json"
292291
json.dump({"image_processor_type": "Gemma3ImageProcessor"}, open(processor_tmpfile, "w"))
293292

294-
torchvision_error = BACKENDS_MAPPING["torchvision"][1]
295-
with patch.dict(BACKENDS_MAPPING, {"torchvision": (lambda: False, torchvision_error)}):
293+
with patch("transformers.models.auto.image_processing_auto.is_torchvision_available", return_value=False):
296294
image_processor = AutoImageProcessor.from_pretrained(tmpdirname)
297295

298296
self.assertEqual(type(image_processor).__name__, "Gemma3ImageProcessorPil")

0 commit comments

Comments
 (0)