mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 08:58:48 +00:00
chroma[patch]: (nit) simplify test (#28517)
Use `self.get_embeddings` on test class instead of importing embeddings separately.
This commit is contained in:
parent
a0130148bc
commit
8bc2c912b8
@ -1,7 +1,6 @@
|
|||||||
from typing import AsyncGenerator, Generator
|
from typing import AsyncGenerator, Generator
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from langchain_core.embeddings.fake import DeterministicFakeEmbedding
|
|
||||||
from langchain_core.vectorstores import VectorStore
|
from langchain_core.vectorstores import VectorStore
|
||||||
from langchain_tests.integration_tests.vectorstores import (
|
from langchain_tests.integration_tests.vectorstores import (
|
||||||
AsyncReadWriteTestSuite,
|
AsyncReadWriteTestSuite,
|
||||||
@ -15,8 +14,7 @@ class TestSync(ReadWriteTestSuite):
|
|||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def vectorstore(self) -> Generator[VectorStore, None, None]: # type: ignore
|
def vectorstore(self) -> Generator[VectorStore, None, None]: # type: ignore
|
||||||
"""Get an empty vectorstore for unit tests."""
|
"""Get an empty vectorstore for unit tests."""
|
||||||
embeddings = DeterministicFakeEmbedding(size=10)
|
store = Chroma(embedding_function=self.get_embeddings())
|
||||||
store = Chroma(embedding_function=embeddings)
|
|
||||||
try:
|
try:
|
||||||
yield store
|
yield store
|
||||||
finally:
|
finally:
|
||||||
@ -28,8 +26,7 @@ class TestAsync(AsyncReadWriteTestSuite):
|
|||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
async def vectorstore(self) -> AsyncGenerator[VectorStore, None]: # type: ignore
|
async def vectorstore(self) -> AsyncGenerator[VectorStore, None]: # type: ignore
|
||||||
"""Get an empty vectorstore for unit tests."""
|
"""Get an empty vectorstore for unit tests."""
|
||||||
embeddings = DeterministicFakeEmbedding(size=10)
|
store = Chroma(embedding_function=self.get_embeddings())
|
||||||
store = Chroma(embedding_function=embeddings)
|
|
||||||
try:
|
try:
|
||||||
yield store
|
yield store
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user