skillfed

langchain-tests

Standard tests for LangChain implementations

langchain-tests v1.1.9 2.0M downloads/30d#3,400 on PyPI144,266
Permissive license MIT Active released

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-tests

uv

uv add langchain-tests

poetry

poetry add langchain-tests

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Tags

langchain integration testingchat model test fixtureslangchain test base classesstandard interface testingintegration test frameworklangchain compliance testsunit test templates
langchain-ecosystemintegration-testingpytest-plugin

More Python Modules packages