refactor(standard-tests): improve VCR config (#33968)

Use of the fixture `_base_vcr_config` is deprecated with alternative
function `base_vcr_config()`
This way:
* we don't need to import `_base_vcr_config` seen as unused (which leads
to ruff violations PLC0414 and F811)
* we don't need to make a copy since a new dict is created at each
function invocation

Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
Christophe Bornet
2025-12-12 16:14:26 +01:00
committed by GitHub
parent a528ea1796
commit f5b6eecf72
7 changed files with 34 additions and 48 deletions

View File

@@ -5,10 +5,7 @@ from importlib import util
from typing import Any
import pytest
from langchain_tests.conftest import CustomPersister, CustomSerializer
from langchain_tests.conftest import (
_base_vcr_config as _base_vcr_config, # noqa: PLC0414
)
from langchain_tests.conftest import CustomPersister, CustomSerializer, base_vcr_config
from vcr import VCR
_EXTRA_HEADERS = [
@@ -34,9 +31,9 @@ def remove_response_headers(response: dict) -> dict:
@pytest.fixture(scope="session")
def vcr_config(_base_vcr_config: dict) -> dict: # noqa: F811
def vcr_config() -> dict:
"""Extend the default configuration coming from langchain_tests."""
config = _base_vcr_config.copy()
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