langchain-tests


Namelangchain-tests JSON
Version 0.3.8 PyPI version JSON
download
home_pagehttps://github.com/langchain-ai/langchain
SummaryStandard tests for LangChain implementations
upload_time2025-01-10 21:59:53
maintainerNone
docs_urlNone
authorErick Friis
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # langchain-tests

This is a testing library for LangChain integrations. It contains the base classes for
a standard set of tests.

## Installation

We encourage pinning your version to a specific version in order to avoid breaking
your CI when we publish new tests. We recommend upgrading to the latest version
periodically to make sure you have the latest tests.

Not pinning your version will ensure you always have the latest tests, but it may
also break your CI if we introduce tests that your integration doesn't pass.

Pip:
    
    ```bash
    pip install -U langchain-tests
    ```

Poetry:
    
    ```bash
    poetry add langchain-tests
    ```

## Usage

To add standard tests to an integration package's e.g. ChatModel, you need to create

1. A unit test class that inherits from ChatModelUnitTests
2. An integration test class that inherits from ChatModelIntegrationTests

`tests/unit_tests/test_standard.py`:
    
```python
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_tests.unit_tests import ChatModelUnitTests

from langchain_parrot_chain import ChatParrotChain


class TestParrotChainStandard(ChatModelUnitTests):
    @pytest.fixture
    def chat_model_class(self) -> Type[BaseChatModel]:
        return ChatParrotChain
```

`tests/integration_tests/test_standard.py`:
    
```python
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_tests.integration_tests import ChatModelIntegrationTests

from langchain_parrot_chain import ChatParrotChain


class TestParrotChainStandard(ChatModelIntegrationTests):
    @pytest.fixture
    def chat_model_class(self) -> Type[BaseChatModel]:
        return ChatParrotChain
```

## Reference

The following fixtures are configurable in the test classes. Anything not marked
as required is optional.

- `chat_model_class` (required): The class of the chat model to be tested
- `chat_model_params`: The keyword arguments to pass to the chat model constructor
- `chat_model_has_tool_calling`: Whether the chat model can call tools. By default, this is set to `hasattr(chat_model_class, 'bind_tools)`
- `chat_model_has_structured_output`: Whether the chat model can structured output. By default, this is set to `hasattr(chat_model_class, 'with_structured_output')`


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/langchain-ai/langchain",
    "name": "langchain-tests",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Erick Friis",
    "author_email": "erick@langchain.dev",
    "download_url": "https://files.pythonhosted.org/packages/ae/19/02f1c54f09c4cd6c91bc8c9d61c47c80ba748aaf26abbb55f6382eeb8bf8/langchain_tests-0.3.8.tar.gz",
    "platform": null,
    "description": "# langchain-tests\n\nThis is a testing library for LangChain integrations. It contains the base classes for\na standard set of tests.\n\n## Installation\n\nWe encourage pinning your version to a specific version in order to avoid breaking\nyour CI when we publish new tests. We recommend upgrading to the latest version\nperiodically to make sure you have the latest tests.\n\nNot pinning your version will ensure you always have the latest tests, but it may\nalso break your CI if we introduce tests that your integration doesn't pass.\n\nPip:\n    \n    ```bash\n    pip install -U langchain-tests\n    ```\n\nPoetry:\n    \n    ```bash\n    poetry add langchain-tests\n    ```\n\n## Usage\n\nTo add standard tests to an integration package's e.g. ChatModel, you need to create\n\n1. A unit test class that inherits from ChatModelUnitTests\n2. An integration test class that inherits from ChatModelIntegrationTests\n\n`tests/unit_tests/test_standard.py`:\n    \n```python\n\"\"\"Standard LangChain interface tests\"\"\"\n\nfrom typing import Type\n\nimport pytest\nfrom langchain_core.language_models import BaseChatModel\nfrom langchain_tests.unit_tests import ChatModelUnitTests\n\nfrom langchain_parrot_chain import ChatParrotChain\n\n\nclass TestParrotChainStandard(ChatModelUnitTests):\n    @pytest.fixture\n    def chat_model_class(self) -> Type[BaseChatModel]:\n        return ChatParrotChain\n```\n\n`tests/integration_tests/test_standard.py`:\n    \n```python\n\"\"\"Standard LangChain interface tests\"\"\"\n\nfrom typing import Type\n\nimport pytest\nfrom langchain_core.language_models import BaseChatModel\nfrom langchain_tests.integration_tests import ChatModelIntegrationTests\n\nfrom langchain_parrot_chain import ChatParrotChain\n\n\nclass TestParrotChainStandard(ChatModelIntegrationTests):\n    @pytest.fixture\n    def chat_model_class(self) -> Type[BaseChatModel]:\n        return ChatParrotChain\n```\n\n## Reference\n\nThe following fixtures are configurable in the test classes. Anything not marked\nas required is optional.\n\n- `chat_model_class` (required): The class of the chat model to be tested\n- `chat_model_params`: The keyword arguments to pass to the chat model constructor\n- `chat_model_has_tool_calling`: Whether the chat model can call tools. By default, this is set to `hasattr(chat_model_class, 'bind_tools)`\n- `chat_model_has_structured_output`: Whether the chat model can structured output. By default, this is set to `hasattr(chat_model_class, 'with_structured_output')`\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Standard tests for LangChain implementations",
    "version": "0.3.8",
    "project_urls": {
        "Homepage": "https://github.com/langchain-ai/langchain",
        "Repository": "https://github.com/langchain-ai/langchain",
        "Source Code": "https://github.com/langchain-ai/langchain/tree/master/libs/standard-tests"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a95adaef5ce7364ced7bae62c7009cec9beebd358e2f9a69bbc014d9eb4d80a6",
                "md5": "d2f9649880e09f1871ef4bc925b03e22",
                "sha256": "009b1bada2ba0422c91fd3961c6e12e30c55ac8c321c85ddc9df670fa14d027c"
            },
            "downloads": -1,
            "filename": "langchain_tests-0.3.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d2f9649880e09f1871ef4bc925b03e22",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 36657,
            "upload_time": "2025-01-10T21:59:50",
            "upload_time_iso_8601": "2025-01-10T21:59:50.923592Z",
            "url": "https://files.pythonhosted.org/packages/a9/5a/daef5ce7364ced7bae62c7009cec9beebd358e2f9a69bbc014d9eb4d80a6/langchain_tests-0.3.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae1902f1c54f09c4cd6c91bc8c9d61c47c80ba748aaf26abbb55f6382eeb8bf8",
                "md5": "3603c7a0b39750abc3b9b6842d21778c",
                "sha256": "8664eeed4a50ba6250ae39ac94231bdba519ccaac82e5eb72ba9062dcbc9eb04"
            },
            "downloads": -1,
            "filename": "langchain_tests-0.3.8.tar.gz",
            "has_sig": false,
            "md5_digest": "3603c7a0b39750abc3b9b6842d21778c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 30229,
            "upload_time": "2025-01-10T21:59:53",
            "upload_time_iso_8601": "2025-01-10T21:59:53.115526Z",
            "url": "https://files.pythonhosted.org/packages/ae/19/02f1c54f09c4cd6c91bc8c9d61c47c80ba748aaf26abbb55f6382eeb8bf8/langchain_tests-0.3.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-10 21:59:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "langchain-ai",
    "github_project": "langchain",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "langchain-tests"
}
        
Elapsed time: 0.53078s