diff --git a/pyproject.toml b/pyproject.toml index fbc6c31f00..2633918fc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ dev-dependencies = [ "dirty-equals>=0.6.0", "importlib-metadata>=6.7.0", "rich>=13.7.1", - "inline-snapshot >=0.7.0", + "inline-snapshot>=0.28.0", "azure-identity >=1.14.1", "types-tqdm > 4", "types-pyaudio > 0", diff --git a/requirements-dev.lock b/requirements-dev.lock index e8bea53014..669378387d 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -90,7 +90,7 @@ idna==3.4 importlib-metadata==7.0.0 iniconfig==2.0.0 # via pytest -inline-snapshot==0.27.0 +inline-snapshot==0.28.0 jiter==0.5.0 # via openai markdown-it-py==3.0.0 diff --git a/tests/lib/chat/test_completions_streaming.py b/tests/lib/chat/test_completions_streaming.py index fa17f67177..548416dfe2 100644 --- a/tests/lib/chat/test_completions_streaming.py +++ b/tests/lib/chat/test_completions_streaming.py @@ -13,6 +13,7 @@ external, snapshot, outsource, # pyright: ignore[reportUnknownVariableType] + get_snapshot_value, ) import openai @@ -30,7 +31,7 @@ ) from openai.lib._parsing._completions import ResponseFormatT -from ..utils import print_obj, get_snapshot_value +from ..utils import print_obj from ...conftest import base_url _T = TypeVar("_T") diff --git a/tests/lib/snapshots.py b/tests/lib/snapshots.py index ed53edebcb..91222acda1 100644 --- a/tests/lib/snapshots.py +++ b/tests/lib/snapshots.py @@ -7,11 +7,10 @@ import httpx from respx import MockRouter +from inline_snapshot import get_snapshot_value from openai import OpenAI, AsyncOpenAI -from .utils import get_snapshot_value - _T = TypeVar("_T") diff --git a/tests/lib/utils.py b/tests/lib/utils.py index 2129ee811a..e6b6a29434 100644 --- a/tests/lib/utils.py +++ b/tests/lib/utils.py @@ -52,15 +52,3 @@ def get_caller_name(*, stacklevel: int = 1) -> str: def clear_locals(string: str, *, stacklevel: int) -> str: caller = get_caller_name(stacklevel=stacklevel + 1) return string.replace(f"{caller}..", "") - - -def get_snapshot_value(snapshot: Any) -> Any: - if not hasattr(snapshot, "_old_value"): - return snapshot - - old = snapshot._old_value - if not hasattr(old, "value"): - return old - - loader = getattr(old.value, "_load_value", None) - return loader() if loader else old.value