test_dependencies.py — langchain Source File
Architecture documentation for test_dependencies.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR fbb85a75_7a9b_0531_9792_14e17ba004c7["test_dependencies.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] fbb85a75_7a9b_0531_9792_14e17ba004c7 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"] fbb85a75_7a9b_0531_9792_14e17ba004c7 --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] fbb85a75_7a9b_0531_9792_14e17ba004c7 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] fbb85a75_7a9b_0531_9792_14e17ba004c7 --> 120e2591_3e15_b895_72b6_cb26195e40a6 87110cc5_7f7f_9e93_8ec9_2c3a2ae425fe["toml"] fbb85a75_7a9b_0531_9792_14e17ba004c7 --> 87110cc5_7f7f_9e93_8ec9_2c3a2ae425fe 6efe7ca1_6cc7_f0eb_d477_b2345bbf8903["packaging.requirements"] fbb85a75_7a9b_0531_9792_14e17ba004c7 --> 6efe7ca1_6cc7_f0eb_d477_b2345bbf8903 style fbb85a75_7a9b_0531_9792_14e17ba004c7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""A unit test meant to catch accidental introduction of non-optional dependencies."""
from collections.abc import Mapping
from pathlib import Path
from typing import Any
import pytest
import toml
from packaging.requirements import Requirement
HERE = Path(__file__).parent
PYPROJECT_TOML = HERE / "../../pyproject.toml"
@pytest.fixture
def uv_conf() -> dict[str, Any]:
"""Load the pyproject.toml file."""
with PYPROJECT_TOML.open() as f:
return toml.load(f)
def test_required_dependencies(uv_conf: Mapping[str, Any]) -> None:
"""A test that checks if a new non-optional dependency is being introduced.
If this test is triggered, it means that a contributor is trying to introduce a new
required dependency. This should be avoided in most situations.
"""
# Get the dependencies from the [tool.poetry.dependencies] section
dependencies = uv_conf["project"]["dependencies"]
required_dependencies = {Requirement(dep).name for dep in dependencies}
assert sorted(required_dependencies) == sorted(
[
"PyYAML",
"SQLAlchemy",
"async-timeout",
"langchain-core",
"langchain-text-splitters",
"langsmith",
"pydantic",
"requests",
],
)
def test_test_group_dependencies(uv_conf: Mapping[str, Any]) -> None:
"""Check if someone is attempting to add additional test dependencies.
Only dependencies associated with test running infrastructure should be added
to the test group; e.g., pytest, pytest-cov etc.
Examples of dependencies that should NOT be included: boto3, azure, postgres, etc.
"""
dependencies = uv_conf["dependency-groups"]["test"]
test_group_deps = {Requirement(dep).name for dep in dependencies}
assert sorted(test_group_deps) == sorted(
[
"freezegun",
"langchain-core",
"langchain-tests",
"langchain-text-splitters",
"langchain-openai",
"lark",
"packaging",
"pandas",
"pytest",
"pytest-asyncio",
"pytest-cov",
"pytest-dotenv",
"pytest-mock",
"pytest-socket",
"pytest-watcher",
"pytest-xdist",
"responses",
"syrupy",
"toml",
"requests-mock",
# TODO: temporary hack since cffi 1.17.1 doesn't work with py 3.9.
"cffi",
"numpy",
],
)
Domain
Subdomains
Dependencies
- collections.abc
- packaging.requirements
- pathlib
- pytest
- toml
- typing
Source
Frequently Asked Questions
What does test_dependencies.py do?
test_dependencies.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_dependencies.py?
test_dependencies.py defines 3 function(s): test_required_dependencies, test_test_group_dependencies, uv_conf.
What does test_dependencies.py depend on?
test_dependencies.py imports 6 module(s): collections.abc, packaging.requirements, pathlib, pytest, toml, typing.
Where is test_dependencies.py in the architecture?
test_dependencies.py is located at libs/langchain/tests/unit_tests/test_dependencies.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/langchain/tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free