Home / File/ conftest.py — langchain Source File

conftest.py — langchain Source File

Architecture documentation for conftest.py, a python file in the langchain codebase. 7 imports, 0 dependents.

File python CoreAbstractions MessageSchema 7 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  66c16def_ac80_446b_fc8e_1ff76a412899["conftest.py"]
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  66c16def_ac80_446b_fc8e_1ff76a412899 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  3888b2bf_bffe_7c16_770f_a406d400119c["importlib"]
  66c16def_ac80_446b_fc8e_1ff76a412899 --> 3888b2bf_bffe_7c16_770f_a406d400119c
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  66c16def_ac80_446b_fc8e_1ff76a412899 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  66c16def_ac80_446b_fc8e_1ff76a412899 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  9eb3be64_a334_606b_b4bd_24e50a8c430d["blockbuster"]
  66c16def_ac80_446b_fc8e_1ff76a412899 --> 9eb3be64_a334_606b_b4bd_24e50a8c430d
  42a409ea_9676_f019_a076_246c8c01ecae["langchain_tests.conftest"]
  66c16def_ac80_446b_fc8e_1ff76a412899 --> 42a409ea_9676_f019_a076_246c8c01ecae
  be04c44e_b094_7140_6a6a_3ec8bbd56d69["vcr"]
  66c16def_ac80_446b_fc8e_1ff76a412899 --> be04c44e_b094_7140_6a6a_3ec8bbd56d69
  style 66c16def_ac80_446b_fc8e_1ff76a412899 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Configuration for unit tests."""

from collections.abc import Iterator, Sequence
from importlib import util
from typing import Any

import pytest
from blockbuster import BlockBuster, blockbuster_ctx
from langchain_tests.conftest import CustomPersister, CustomSerializer, base_vcr_config
from vcr import VCR

_EXTRA_HEADERS = [
    ("openai-organization", "PLACEHOLDER"),
    ("user-agent", "PLACEHOLDER"),
    ("x-openai-client-user-agent", "PLACEHOLDER"),
]


@pytest.fixture(autouse=True)
def blockbuster() -> Iterator[BlockBuster]:
    with blockbuster_ctx() as bb:
        yield bb


def remove_request_headers(request: Any) -> Any:
    """Remove sensitive headers from the request."""
    for k in request.headers:
        request.headers[k] = "**REDACTED**"
    request.uri = "**REDACTED**"
    return request


def remove_response_headers(response: dict[str, Any]) -> dict[str, Any]:
    """Remove sensitive headers from the response."""
    for k in response["headers"]:
        response["headers"][k] = "**REDACTED**"
    return response


@pytest.fixture(scope="session")
def vcr_config() -> dict[str, Any]:
    """Extend the default configuration coming from langchain_tests."""
    config = base_vcr_config()
    config.setdefault("filter_headers", []).extend(_EXTRA_HEADERS)
    config["before_record_request"] = remove_request_headers
    config["before_record_response"] = remove_response_headers
    config["serializer"] = "yaml.gz"
    config["path_transformer"] = VCR.ensure_suffix(".yaml.gz")
    return config


def pytest_recording_configure(config: dict[str, Any], vcr: VCR) -> None:  # noqa: ARG001
    vcr.register_persister(CustomPersister())
    vcr.register_serializer("yaml.gz", CustomSerializer())


def pytest_addoption(parser: pytest.Parser) -> None:
    """Add custom command line options to pytest."""
    parser.addoption(
        "--only-extended",
// ... (75 more lines)

Subdomains

Dependencies

  • blockbuster
  • collections.abc
  • importlib
  • langchain_tests.conftest
  • pytest
  • typing
  • vcr

Frequently Asked Questions

What does conftest.py do?
conftest.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 conftest.py?
conftest.py defines 7 function(s): blockbuster, pytest_addoption, pytest_collection_modifyitems, pytest_recording_configure, remove_request_headers, remove_response_headers, vcr_config.
What does conftest.py depend on?
conftest.py imports 7 module(s): blockbuster, collections.abc, importlib, langchain_tests.conftest, pytest, typing, vcr.
Where is conftest.py in the architecture?
conftest.py is located at libs/langchain_v1/tests/unit_tests/conftest.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/langchain_v1/tests/unit_tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free