mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
standard-tests[patch]: Add pytest assert rewrites (#24408)
This will surface nice error messages in subclasses that fail assertions.
This commit is contained in:
parent
f62b323108
commit
ef22ebe431
@ -1,6 +1,35 @@
|
||||
from typing import Tuple
|
||||
|
||||
import pytest
|
||||
from langchain_standard_tests.integration_tests.base_store import (
|
||||
BaseStoreAsyncTests,
|
||||
BaseStoreSyncTests,
|
||||
)
|
||||
|
||||
from langchain_core.stores import InMemoryStore
|
||||
|
||||
|
||||
# Check against standard tests
|
||||
class TestSyncInMemoryStore(BaseStoreSyncTests):
|
||||
@pytest.fixture
|
||||
def kv_store(self) -> InMemoryStore:
|
||||
return InMemoryStore()
|
||||
|
||||
@pytest.fixture
|
||||
def three_values(self) -> Tuple[str, str, str]: # type: ignore
|
||||
return "value1", "value2", "value3"
|
||||
|
||||
|
||||
class TestAsyncInMemoryStore(BaseStoreAsyncTests):
|
||||
@pytest.fixture
|
||||
async def kv_store(self) -> InMemoryStore:
|
||||
return InMemoryStore()
|
||||
|
||||
@pytest.fixture
|
||||
def three_values(self) -> Tuple[str, str, str]: # type: ignore
|
||||
return "value1", "value2", "value3"
|
||||
|
||||
|
||||
def test_mget() -> None:
|
||||
store = InMemoryStore()
|
||||
store.mset([("key1", "value1"), ("key2", "value2")])
|
||||
|
@ -1,3 +1,21 @@
|
||||
# ruff: noqa: E402
|
||||
import pytest
|
||||
|
||||
# Rewrite assert statements for test suite so that implementations can
|
||||
# see the full error message from failed asserts.
|
||||
# https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#assertion-rewriting
|
||||
modules = [
|
||||
"base_store",
|
||||
"cache",
|
||||
"chat_models",
|
||||
"vectorstores",
|
||||
]
|
||||
|
||||
for module in modules:
|
||||
pytest.register_assert_rewrite(
|
||||
f"langchain_standard_tests.integration_tests.{module}"
|
||||
)
|
||||
|
||||
from langchain_standard_tests.integration_tests.chat_models import (
|
||||
ChatModelIntegrationTests,
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Test suite to test vectostores."""
|
||||
|
||||
import inspect
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
# ruff: noqa: E402
|
||||
import pytest
|
||||
|
||||
# Rewrite assert statements for test suite so that implementations can
|
||||
# see the full error message from failed asserts.
|
||||
# https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#assertion-rewriting
|
||||
modules = [
|
||||
"chat_models",
|
||||
]
|
||||
|
||||
for module in modules:
|
||||
pytest.register_assert_rewrite(f"langchain_standard_tests.unit_tests.{module}")
|
||||
|
||||
from langchain_standard_tests.unit_tests.chat_models import ChatModelUnitTests
|
||||
|
||||
__all__ = ["ChatModelUnitTests"]
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Tests for the InMemoryStore class."""
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
import pytest
|
||||
|
Loading…
Reference in New Issue
Block a user