fix: reject invalid embedding input containers

This commit is contained in:
2026-10-16 09:14:31 +08:00
parent cf4e65bb9d
commit 97c9ea2cb4
3 changed files with 14 additions and 3 deletions
+7
View File
@@ -118,3 +118,10 @@ def test_invalid_resource_options_fail_without_loading_optional_dependencies(opt
def test_unsupported_checkpoint_format_is_rejected(checkpoint):
with pytest.raises(EmbeddingError):
replace(SMALL_ZH, checkpoint_format=checkpoint)
@pytest.mark.parametrize("texts", [None, "不能逐字编码的字符串", ("占位",), [None], [" "]])
def test_input_shape_and_text_are_validated_before_encoding(texts):
provider = object.__new__(LocalEmbeddingProvider)
with pytest.raises(EmbeddingError):
provider.encode(texts)