Skip to content
Snippets Groups Projects
Commit 7a534ced authored by James Briggs's avatar James Briggs
Browse files

fix: tests and errors messages

parent 567e4c9f
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ class VitEncoder(BaseEncoder):
from transformers import ViTImageProcessor, ViTModel
except ImportError:
raise ImportError(
"Please install transformers to use HuggingFaceEncoder. "
"Please install transformers to use VitEncoder. "
"You can install it with: "
"`pip install semantic-router[vision]`"
)
......@@ -37,7 +37,7 @@ class VitEncoder(BaseEncoder):
import torchvision.transforms as T
except ImportError:
raise ImportError(
"Please install Pytorch to use HuggingFaceEncoder. "
"Please install Pytorch to use VitEncoder. "
"You can install it with: "
"`pip install semantic-router[vision]`"
)
......@@ -46,7 +46,7 @@ class VitEncoder(BaseEncoder):
from PIL import Image
except ImportError:
raise ImportError(
"Please install PIL to use HuggingFaceEncoder. "
"Please install PIL to use VitEncoder. "
"You can install it with: "
"`pip install semantic-router[vision]`"
)
......
from unittest.mock import patch
import os
import numpy as np
import pytest
......@@ -33,15 +35,14 @@ def misshaped_pil_image():
class TestVitEncoder:
def test_vit_encoder__import_errors_transformers(self, mocker):
mocker.patch.dict("sys.modules", {"transformers": None})
with pytest.raises(ImportError):
VitEncoder()
def test_vit_encoder__import_errors_torch(self, mocker):
mocker.patch.dict("sys.modules", {"torch": None})
with pytest.raises(ImportError):
VitEncoder()
def test_vit_encoder__import_errors_transformers(self):
with patch.dict("sys.modules", {"transformers": None}):
with pytest.raises(ImportError) as error:
VitEncoder()
assert "Please install transformers to use VitEncoder" in str(
error.value
)
@pytest.mark.skipif(
os.environ.get("RUN_HF_TESTS") is None, reason="Set RUN_HF_TESTS=1 to run"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment