conftest.py — langchain Source File
Architecture documentation for conftest.py, a python file in the langchain codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6bde641f_b1b2_4174_658b_272fb87e1c83["conftest.py"] 2915ba82_8a9c_f640_b135_cf3e32833f88["gzip"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> 2915ba82_8a9c_f640_b135_cf3e32833f88 b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> 120e2591_3e15_b895_72b6_cb26195e40a6 6a4c8a76_d409_3b0b_3e3a_9dfaef8d20fb["yaml"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> 6a4c8a76_d409_3b0b_3e3a_9dfaef8d20fb 2d1edd36_20be_d887_f834_7b58c1b5a50f["langchain_core._api.deprecation"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> 2d1edd36_20be_d887_f834_7b58c1b5a50f be04c44e_b094_7140_6a6a_3ec8bbd56d69["vcr"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> be04c44e_b094_7140_6a6a_3ec8bbd56d69 3008e06b_18d4_bffd_8ea9_e0886981f3ee["vcr.persisters.filesystem"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> 3008e06b_18d4_bffd_8ea9_e0886981f3ee d93bedc9_1b8f_8d26_706c_acc3c3df8d31["vcr.request"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> d93bedc9_1b8f_8d26_706c_acc3c3df8d31 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"] 6bde641f_b1b2_4174_658b_272fb87e1c83 --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c style 6bde641f_b1b2_4174_658b_272fb87e1c83 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Pytest conftest."""
from __future__ import annotations
import gzip
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
import pytest
import yaml
from langchain_core._api.deprecation import deprecated
from vcr import VCR
from vcr.persisters.filesystem import CassetteNotFoundError
from vcr.request import Request
if TYPE_CHECKING:
from os import PathLike
class CustomSerializer:
"""Custom serializer for VCR cassettes using YAML and gzip.
We're using a custom serializer to avoid the default yaml serializer
used by VCR, which is not designed to be safe for untrusted input.
This step is an extra precaution necessary because the cassette files
are in compressed YAML format, which makes it more difficult to inspect
their contents during development or debugging.
"""
@staticmethod
def serialize(cassette_dict: dict[str, Any]) -> bytes:
"""Convert cassette to YAML and compress it."""
cassette_dict["requests"] = [
{
"method": request.method,
"uri": request.uri,
"body": request.body,
"headers": {k: [v] for k, v in request.headers.items()},
}
for request in cassette_dict["requests"]
]
yml = yaml.safe_dump(cassette_dict)
return gzip.compress(yml.encode("utf-8"))
@staticmethod
def deserialize(data: bytes) -> dict[str, Any]:
"""Decompress data and convert it from YAML."""
decoded_yaml = gzip.decompress(data).decode("utf-8")
cassette = cast("dict[str, Any]", yaml.safe_load(decoded_yaml))
cassette["requests"] = [Request(**request) for request in cassette["requests"]]
return cassette
class CustomPersister:
"""A custom persister for VCR that uses the `CustomSerializer`."""
@classmethod
def load_cassette(
cls,
// ... (68 more lines)
Domain
Subdomains
Classes
Dependencies
- gzip
- langchain_core._api.deprecation
- os
- pathlib
- pytest
- typing
- vcr
- vcr.persisters.filesystem
- vcr.request
- yaml
Source
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): _base_vcr_config, base_vcr_config, os, vcr_config.
What does conftest.py depend on?
conftest.py imports 10 module(s): gzip, langchain_core._api.deprecation, os, pathlib, pytest, typing, vcr, vcr.persisters.filesystem, and 2 more.
Where is conftest.py in the architecture?
conftest.py is located at libs/standard-tests/langchain_tests/conftest.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/standard-tests/langchain_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free