mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-25 04:49:17 +00:00
standard-tests: migrate to pytest-recording (#31425)
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
Binary file not shown.
@@ -1 +0,0 @@
|
||||
H4sIABh0OGgC/9Vb328bNxJ+z1/B7ouBQKvYTnt30JvPcS+9tsghMdAUVWFQuyMtT7vkluRKVgL/7/eR+0O7tlRLPtSg8xKLGpIzw5lvZsiRkJY0T6xQ0kxexUzTHxUZO3nF8G+m0s2EnXyNCn57Y9WSpIkmZ6fn346igozhC8Ln375GWuUUTaLKkI5GUaKwprQY+EULS4wzY5Xe+BUZ4zNVWYwl3I6ju9+xkkopB3GS8yql+G38XWyUlGTjnFuwghWN1cSLaGJ1RXcnfqGMeEraTNpVk4RK236K2cnr1x+v3l1cXl+9e/36ZEAUk0xUKuTiMWppM61KkcQrbAT9PEKfOKa9Ih8ndPqJc5ILmx1IbDclPUKaKfOYBtwJxTg2+RjhbcxLES9p8yidsVzIHNYQc51kx5CbjUyOoM/5o0fWJ1fmCOKSJ0uo5cCT7s/UZPUmTlR1gEp7s0AuCjp+xhM4dNPgcn86oyCbqXTC/vPh07UfqLSYsMza0kzevIEpjDtvGCeqeLM6e9MCAMg1mRLwQT3QaDaD4zpHYxGtnM2xZtINuNN2KlNu+YR9nUbOuqfRZBoNCaJRN4JvQSfSmsosbk7PrtKfKPuHnt3+69+f//5P8d93n69/ffvFT7q/nh90KOUHuTECG8hmA4c/fvwhAp0D64B3556wcUWQ/vY7PgLUyhvgEkgxJKs8bweNw1CZ0Ha46okgy8o2YIqRs2/dyjzJ6CbBYg4+bu6RnHYUIEh3fYvjHS7qOCG9EgndWEHaS+ckTrmGBu/umuNhbNr+cTeVU9mcUiPozSxXyXL/We0ic3oSMqXblu8+Ta2Abr6l23pC/QdGwNpDzh7yV8KmHjLEppH/ItovCg7a8mZmt9F+kWry+yI1ow9E6ZF3Ar0nTXuEOozLv5S7E9Mx1sTofnQGwV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RwgCQjf5NbP24c7qrPHBwd7032Z9wtNOwkZWotUTokCEIPvTZUx3WGjmyvriNU7lqf/OCcr5Rv0HLdVdaM2ydWbg+uQZ9XEunubkcMsNnhKaq7HMdSlSijQ7sf7avY5QRM1ZW+aS4YQ4hQcz4w+LLS7mKl2YVQ1jjPFTm9gADF2z4AeKtLYug2EbZ9hEwpQRYTavrVf71wrLvMQCrrXxzrGzuXjCHFaUEnzKfqAjh/nfn7XX8jd3z980xazpVaAtz1mmuf4a6EEYM0LKz39bZI4wsuJOCjoKAjT8o324an6vz07C0rSWe8RPHmn7S6V9yQ1OxZkwoY7co2qwpEfLXugiKF/DjRbXIl0z+Ngq498ZBWPlAN+NnZldffpu3b3HtuQ4JoKOCwlRLZu0xvgOTS0+1qqbwb9lTe7398+7fzgxoJt92mu9Uy+D7qregXiXY1ol9+H3+8+HWyuy330uW+8SWUrVW+j2bbRr6XwHeEX7uO8N0k77jd99Un0ivSe7681lyaOen4qm2R3033Of6oZsqa+JrvI9l2zyuNwlx88S/FsUgfpddgPheFsLHvdI3rU4390FMnayoAnfsFOmABQ8fsXlvkU3kfzn4K8/dXOI775kcgxzPeTXwKz73Jx7H7RC3/H+o9QK/JPPZN264T31ZmD1Uj836/cB30CTZ0nlkqbWND7kXLbvbQrwTf+U3DRferkhQAcX7aAnsDdBP24cdX7S8M2Nmr/wGjq7kFHTQAAA==
|
@@ -1,7 +1,7 @@
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from langchain_tests.conftest import YamlGzipSerializer
|
||||
from langchain_tests.conftest import CustomPersister, CustomSerializer
|
||||
from langchain_tests.conftest import _base_vcr_config as _base_vcr_config
|
||||
from vcr import VCR # type: ignore[import-untyped]
|
||||
|
||||
@@ -32,9 +32,6 @@ def vcr_config(_base_vcr_config: dict) -> dict: # noqa: F811
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def vcr(vcr_config: dict) -> VCR:
|
||||
"""Override the default vcr fixture to include custom serializers"""
|
||||
my_vcr = VCR(**vcr_config)
|
||||
my_vcr.register_serializer("yaml.gz", YamlGzipSerializer)
|
||||
return my_vcr
|
||||
def pytest_recording_configure(config: dict, vcr: VCR) -> None:
|
||||
vcr.register_persister(CustomPersister())
|
||||
vcr.register_serializer("yaml.gz", CustomSerializer())
|
||||
|
32
libs/partners/anthropic/uv.lock
generated
32
libs/partners/anthropic/uv.lock
generated
@@ -502,7 +502,7 @@ typing = [
|
||||
|
||||
[[package]]
|
||||
name = "langchain-core"
|
||||
version = "0.3.62"
|
||||
version = "0.3.63"
|
||||
source = { editable = "../../core" }
|
||||
dependencies = [
|
||||
{ name = "jsonpatch" },
|
||||
@@ -571,8 +571,8 @@ dependencies = [
|
||||
{ name = "pytest-asyncio" },
|
||||
{ name = "pytest-benchmark" },
|
||||
{ name = "pytest-codspeed" },
|
||||
{ name = "pytest-recording" },
|
||||
{ name = "pytest-socket" },
|
||||
{ name = "pytest-vcr" },
|
||||
{ name = "syrupy" },
|
||||
{ name = "vcrpy" },
|
||||
]
|
||||
@@ -587,8 +587,8 @@ requires-dist = [
|
||||
{ name = "pytest-asyncio", specifier = ">=0.20,<1" },
|
||||
{ name = "pytest-benchmark" },
|
||||
{ name = "pytest-codspeed" },
|
||||
{ name = "pytest-recording" },
|
||||
{ name = "pytest-socket", specifier = ">=0.6.0,<1" },
|
||||
{ name = "pytest-vcr" },
|
||||
{ name = "syrupy", specifier = ">=4,<5" },
|
||||
{ name = "vcrpy", specifier = ">=7.0" },
|
||||
]
|
||||
@@ -1339,6 +1339,19 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/3b/b26f90f74e2986a82df6e7ac7e319b8ea7ccece1caec9f8ab6104dc70603/pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f", size = 9863 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-recording"
|
||||
version = "0.13.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pytest" },
|
||||
{ name = "vcrpy" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/32/9c/f4027c5f1693847b06d11caf4b4f6bb09f22c1581ada4663877ec166b8c6/pytest_recording-0.13.4.tar.gz", hash = "sha256:568d64b2a85992eec4ae0a419c855d5fd96782c5fb016784d86f18053792768c", size = 26576 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/42/c2/ce34735972cc42d912173e79f200fe66530225190c06655c5632a9d88f1e/pytest_recording-0.13.4-py3-none-any.whl", hash = "sha256:ad49a434b51b1c4f78e85b1e6b74fdcc2a0a581ca16e52c798c6ace971f7f439", size = 13723 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-retry"
|
||||
version = "1.7.0"
|
||||
@@ -1375,19 +1388,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/03/27/14af9ef8321f5edc7527e47def2a21d8118c6f329a9342cc61387a0c0599/pytest_timeout-2.3.1-py3-none-any.whl", hash = "sha256:68188cb703edfc6a18fad98dc25a3c61e9f24d644b0b70f33af545219fc7813e", size = 14148 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-vcr"
|
||||
version = "1.0.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pytest" },
|
||||
{ name = "vcrpy" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/1a/60/104c619483c1a42775d3f8b27293f1ecfc0728014874d065e68cb9702d49/pytest-vcr-1.0.2.tar.gz", hash = "sha256:23ee51b75abbcc43d926272773aae4f39f93aceb75ed56852d0bf618f92e1896", size = 3810 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/9d/d3/ff520d11e6ee400602711d1ece8168dcfc5b6d8146fb7db4244a6ad6a9c3/pytest_vcr-1.0.2-py2.py3-none-any.whl", hash = "sha256:2f316e0539399bea0296e8b8401145c62b6f85e9066af7e57b6151481b0d6d9c", size = 4137 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-watcher"
|
||||
version = "0.4.3"
|
||||
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from langchain_tests.conftest import YamlGzipSerializer
|
||||
from langchain_tests.conftest import CustomPersister, CustomSerializer
|
||||
from langchain_tests.conftest import _base_vcr_config as _base_vcr_config
|
||||
from vcr import VCR # type: ignore[import-untyped]
|
||||
|
||||
@@ -13,6 +13,7 @@ _EXTRA_HEADERS = [
|
||||
|
||||
|
||||
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**"
|
||||
@@ -20,6 +21,7 @@ def remove_request_headers(request: Any) -> Any:
|
||||
|
||||
|
||||
def remove_response_headers(response: dict) -> dict:
|
||||
"""Remove sensitive headers from the response."""
|
||||
for k in response["headers"]:
|
||||
response["headers"][k] = "**REDACTED**"
|
||||
return response
|
||||
@@ -27,22 +29,16 @@ def remove_response_headers(response: dict) -> dict:
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def vcr_config(_base_vcr_config: dict) -> dict: # noqa: F811
|
||||
"""
|
||||
Extend the default configuration coming from langchain_tests.
|
||||
"""
|
||||
"""Extend the default configuration coming from langchain_tests."""
|
||||
config = _base_vcr_config.copy()
|
||||
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
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def vcr(vcr_config: dict) -> VCR:
|
||||
"""Override the default vcr fixture to include custom serializers"""
|
||||
my_vcr = VCR(**vcr_config)
|
||||
my_vcr.register_serializer("yaml.gz", YamlGzipSerializer)
|
||||
return my_vcr
|
||||
def pytest_recording_configure(config: dict, vcr: VCR) -> None:
|
||||
vcr.register_persister(CustomPersister())
|
||||
vcr.register_serializer("yaml.gz", CustomSerializer())
|
||||
|
32
libs/partners/openai/uv.lock
generated
32
libs/partners/openai/uv.lock
generated
@@ -479,7 +479,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "langchain-core"
|
||||
version = "0.3.62"
|
||||
version = "0.3.63"
|
||||
source = { editable = "../../core" }
|
||||
dependencies = [
|
||||
{ name = "jsonpatch" },
|
||||
@@ -637,8 +637,8 @@ dependencies = [
|
||||
{ name = "pytest-asyncio" },
|
||||
{ name = "pytest-benchmark" },
|
||||
{ name = "pytest-codspeed" },
|
||||
{ name = "pytest-recording" },
|
||||
{ name = "pytest-socket" },
|
||||
{ name = "pytest-vcr" },
|
||||
{ name = "syrupy" },
|
||||
{ name = "vcrpy" },
|
||||
]
|
||||
@@ -653,8 +653,8 @@ requires-dist = [
|
||||
{ name = "pytest-asyncio", specifier = ">=0.20,<1" },
|
||||
{ name = "pytest-benchmark" },
|
||||
{ name = "pytest-codspeed" },
|
||||
{ name = "pytest-recording" },
|
||||
{ name = "pytest-socket", specifier = ">=0.6.0,<1" },
|
||||
{ name = "pytest-vcr" },
|
||||
{ name = "syrupy", specifier = ">=4,<5" },
|
||||
{ name = "vcrpy", specifier = ">=7.0" },
|
||||
]
|
||||
@@ -1514,6 +1514,19 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/3b/b26f90f74e2986a82df6e7ac7e319b8ea7ccece1caec9f8ab6104dc70603/pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f", size = 9863 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-recording"
|
||||
version = "0.13.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pytest" },
|
||||
{ name = "vcrpy" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/32/9c/f4027c5f1693847b06d11caf4b4f6bb09f22c1581ada4663877ec166b8c6/pytest_recording-0.13.4.tar.gz", hash = "sha256:568d64b2a85992eec4ae0a419c855d5fd96782c5fb016784d86f18053792768c", size = 26576 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/42/c2/ce34735972cc42d912173e79f200fe66530225190c06655c5632a9d88f1e/pytest_recording-0.13.4-py3-none-any.whl", hash = "sha256:ad49a434b51b1c4f78e85b1e6b74fdcc2a0a581ca16e52c798c6ace971f7f439", size = 13723 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-retry"
|
||||
version = "1.7.0"
|
||||
@@ -1538,19 +1551,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/19/58/5d14cb5cb59409e491ebe816c47bf81423cd03098ea92281336320ae5681/pytest_socket-0.7.0-py3-none-any.whl", hash = "sha256:7e0f4642177d55d317bbd58fc68c6bd9048d6eadb2d46a89307fa9221336ce45", size = 6754 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-vcr"
|
||||
version = "1.0.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pytest" },
|
||||
{ name = "vcrpy" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/1a/60/104c619483c1a42775d3f8b27293f1ecfc0728014874d065e68cb9702d49/pytest-vcr-1.0.2.tar.gz", hash = "sha256:23ee51b75abbcc43d926272773aae4f39f93aceb75ed56852d0bf618f92e1896", size = 3810 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/9d/d3/ff520d11e6ee400602711d1ece8168dcfc5b6d8146fb7db4244a6ad6a9c3/pytest_vcr-1.0.2-py2.py3-none-any.whl", hash = "sha256:2f316e0539399bea0296e8b8401145c62b6f85e9066af7e57b6151481b0d6d9c", size = 4137 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-watcher"
|
||||
version = "0.4.3"
|
||||
|
Reference in New Issue
Block a user