langchain-tests provides a collection of standard unit and integration tests designed for verifying LangChain implementations and integrations. It ensures consistent behavior across various components (e.g., LLMs, ChatModels, Embeddings, Retrievers). The library is part of the broader LangChain ecosystem and sees frequent updates, typically alongside `langchain-core` releases. The current version is 1.1.6.
pip install langchain-tests pytestNo compatibility data collected yet for this library.
The primary way to use `langchain-tests` is by running `pytest` to discover and execute its test modules. This example shows how to programmatically invoke `pytest` to run all tests within the `langchain_tests` package.
When building a new integration, derive your test classes from `langchain_core.utils.standard_tests.StandardTestSuite` and implement its abstract methods. Then, use `pytest` to discover and run your implementation alongside the standard `langchain-tests`.
Consult the LangChain documentation for the specific integration you are testing to understand its environmental requirements. Ensure all necessary API keys and service endpoints are correctly configured as environment variables or passed during test setup.
To execute the tests, use `pytest --pyargs langchain_tests` in your terminal. If you need to write custom tests for your integration, you'll typically interact with base classes and utilities from `langchain-core`.
Always install `langchain-tests` with a version that aligns with your `langchain-core` installation. Check the `pyproject.toml` of `langchain-tests` on GitHub for its exact `langchain-core` dependency range. It is often safest to upgrade both packages concurrently.
Update your import statements to reflect the new modular structure, for example, `from langchain_community.retrievers import ...` and ensure `langchain-community` is installed.
Refactor your code to use LCEL's recommended approach for chaining runnables and accessing their outputs, typically by invoking the `RunnableSequence` or accessing its dictionary output, rather than relying on legacy chain attributes. You might need to adjust your tests to interact with LCEL objects as opaque pipelines.
Explicitly define the type hints for attributes like 'name' in your Pydantic models being tested, or update `langchain-tests` and related `langchain-core` packages to versions compatible with Python 3.14 that address this Pydantic behavior.
Install the missing dependency using pip: `pip install qdrant-client`. Ensure all optional dependencies required by the integration you are testing are installed.