langchain-tests
Standard tests for LangChain implementations
What it is and what it does
langchain-tests is a testing library that provides standardized test base classes and fixtures for validating LangChain integrations. It defines unit and integration test templates (e.g., ChatModelUnitTests, ChatModelIntegrationTests) that integration authors inherit from to ensure their implementations conform to LangChain's standard interfaces. The library bundles pytest plugins (pytest-asyncio, pytest-benchmark, pytest-recording, pytest-socket, vcrpy) and assertion tools (syrupy) to support deterministic, isolated testing.
Integration packages use langchain-tests by creating test classes that inherit from the appropriate base and configure fixtures like chat_model_class and optional parameters such as tool-calling and structured-output capabilities. The library is actively maintained by the LangChain team and released frequently; the documentation explicitly recommends pinning to a specific version in CI to prevent unexpected test failures when new tests are introduced.
Use it for:
- Validate a custom chat model integration against LangChain's standard interface before publishing.
- Ensure a third-party LLM provider integration passes unit and integration tests in CI/CD.
- Add deterministic, recorded HTTP tests to an integration using pytest-recording and vcrpy.
- Benchmark performance of a chat model integration with pytest-benchmark fixtures.
- Test tool-calling and structured-output capabilities of a chat model implementation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides standard test base classes and fixtures for validating LangChain integration implementations, particularly chat models, against a shared interface contract.
Yes, if you are developing a LangChain integration (chat model, retriever, or other component). It provides the canonical test suite and fixtures the LangChain ecosystem expects, with low install friction and active maintenance. Not relevant for end users of LangChain who are not building integrations. Pin the version in your CI to avoid unexpected test additions breaking your pipeline.
Install
langchain-tests on PyPI
pip
pip install langchain-testsuv
uv add langchain-testspoetry
poetry add langchain-testsInstalling langchain-tests
Before you install
Low friction install with a pure-Python wheel. Active maintenance (last commit 2026-08-14) and recent release (2026-05-21). Documentation recommends pinning versions to avoid CI breakage when new tests are added.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal restrictions.
Quickstart
pip install langchain-tests
from langchain_tests.unit_tests import ChatModelUnitTests
from langchain_core.language_models import BaseChatModel
class TestMyModel(ChatModelUnitTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return MyCustomChatModel
Requires Python 3.10 or later; integrations must inherit from langchain-core base classes.
Verify before relying
- Whether test coverage includes all LangChain integration types beyond chat models (e.g., retrievers, agents).
- Performance impact of running the full test suite on typical CI pipelines.
- Compatibility guarantees across langchain-core versions when pinning is not used.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0.0,>=3.10.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 11 — httpx, langchain-core, numpy, pytest-asyncio, pytest-benchmark, pytest-codspeed, pytest-recording, pytest-socket, pytest, syrupy, vcrpy |
| Maintenance | actively maintained — 85 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,969,745/month — #3,400 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: langchain_tests-1.1.9-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
langchain-openaiProvides LangChain integrations for OpenAI's…
permissive · top 1,000 on PyPI
langchain-groqConnects Groq's inference API to LangChain,…
permissive · top 5,000 on PyPI
langchain-deepseekIntegrates DeepSeek language models into…
permissive · top 5,000 on PyPI
langchain-ollamaConnects LangChain applications to Ollama,…
permissive · top 5,000 on PyPI
langchain-google-communityConnects Google products and services to…
permissive · top 5,000 on PyPI
langchain-perplexityIntegrates Perplexity AI models into LangChain…
permissive · top 15,000 on PyPI
langchain-xaiConnects xAI's language models to LangChain…
permissive · top 5,000 on PyPI
langchain-google-genaiIntegrates Google's Gemini AI models (chat,…
permissive · top 5,000 on PyPI
langchain-classicProvides legacy LangChain chains, community…
permissive · top 1,000 on PyPI
langchain-awsConnects LangChain applications to AWS services…
permissive · top 5,000 on PyPI