Home / File/ conftest.py — langchain Source File

conftest.py — langchain Source File

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

File python CoreAbstractions MessageSchema 4 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  741820ec_4452_a560_4877_cc4e4fde941c["conftest.py"]
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  741820ec_4452_a560_4877_cc4e4fde941c --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  741820ec_4452_a560_4877_cc4e4fde941c --> 120e2591_3e15_b895_72b6_cb26195e40a6
  42a409ea_9676_f019_a076_246c8c01ecae["langchain_tests.conftest"]
  741820ec_4452_a560_4877_cc4e4fde941c --> 42a409ea_9676_f019_a076_246c8c01ecae
  be04c44e_b094_7140_6a6a_3ec8bbd56d69["vcr"]
  741820ec_4452_a560_4877_cc4e4fde941c --> be04c44e_b094_7140_6a6a_3ec8bbd56d69
  style 741820ec_4452_a560_4877_cc4e4fde941c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Any

import pytest
from langchain_tests.conftest import CustomPersister, CustomSerializer, base_vcr_config
from vcr import VCR  # type: ignore[import-untyped]

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


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) -> dict:
    """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:
    """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, vcr: VCR) -> None:
    vcr.register_persister(CustomPersister())
    vcr.register_serializer("yaml.gz", CustomSerializer())

Subdomains

Dependencies

  • 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 4 function(s): pytest_recording_configure, remove_request_headers, remove_response_headers, vcr_config.
What does conftest.py depend on?
conftest.py imports 4 module(s): langchain_tests.conftest, pytest, typing, vcr.
Where is conftest.py in the architecture?
conftest.py is located at libs/partners/openai/tests/conftest.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/openai/tests).

Analyze Your Own Codebase

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

Try Supermodel Free