Skip to content

Commit e236fde

Browse files
committed
chore(tests): bump inline-snapshot dependency
1 parent a825874 commit e236fde

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

requirements-dev.lock

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ attrs==24.2.0
3535
azure-core==1.31.0
3636
# via azure-identity
3737
azure-identity==1.19.0
38-
black==24.10.0
39-
# via inline-snapshot
4038
certifi==2023.7.22
4139
# via httpcore
4240
# via httpx
@@ -46,9 +44,6 @@ cffi==1.16.0
4644
# via sounddevice
4745
charset-normalizer==3.3.2
4846
# via requests
49-
click==8.1.7
50-
# via black
51-
# via inline-snapshot
5247
colorlog==6.7.0
5348
# via nox
5449
cryptography==42.0.7
@@ -66,7 +61,7 @@ exceptiongroup==1.2.2
6661
# via trio
6762
execnet==2.1.1
6863
# via pytest-xdist
69-
executing==2.1.0
64+
executing==2.2.0
7065
# via inline-snapshot
7166
filelock==3.12.4
7267
# via virtualenv
@@ -92,7 +87,7 @@ idna==3.4
9287
importlib-metadata==7.0.0
9388
iniconfig==2.0.0
9489
# via pytest
95-
inline-snapshot==0.10.2
90+
inline-snapshot==0.27.0
9691
jiter==0.5.0
9792
# via openai
9893
markdown-it-py==3.0.0
@@ -109,7 +104,6 @@ multidict==6.5.0
109104
# via yarl
110105
mypy==1.14.1
111106
mypy-extensions==1.0.0
112-
# via black
113107
# via mypy
114108
nest-asyncio==1.6.0
115109
nodeenv==1.8.0
@@ -122,17 +116,13 @@ numpy==2.0.2
122116
outcome==1.3.0.post0
123117
# via trio
124118
packaging==23.2
125-
# via black
126119
# via nox
127120
# via pytest
128121
pandas==2.2.3
129122
# via openai
130123
pandas-stubs==2.1.4.231227
131124
# via openai
132-
pathspec==0.12.1
133-
# via black
134125
platformdirs==3.11.0
135-
# via black
136126
# via virtualenv
137127
pluggy==1.5.0
138128
# via pytest
@@ -148,11 +138,13 @@ pydantic==2.10.3
148138
pydantic-core==2.27.1
149139
# via pydantic
150140
pygments==2.18.0
141+
# via pytest
151142
# via rich
152143
pyjwt==2.8.0
153144
# via msal
154145
pyright==1.1.399
155-
pytest==8.3.3
146+
pytest==8.4.1
147+
# via inline-snapshot
156148
# via pytest-asyncio
157149
# via pytest-xdist
158150
pytest-asyncio==0.24.0
@@ -185,10 +177,8 @@ sortedcontainers==2.4.0
185177
sounddevice==0.5.1
186178
# via openai
187179
time-machine==2.9.0
188-
toml==0.10.2
189-
# via inline-snapshot
190180
tomli==2.0.2
191-
# via black
181+
# via inline-snapshot
192182
# via mypy
193183
# via pytest
194184
tqdm==4.66.5
@@ -197,13 +187,10 @@ trio==0.27.0
197187
types-pyaudio==0.2.16.20240516
198188
types-pytz==2024.2.0.20241003
199189
# via pandas-stubs
200-
types-toml==0.10.8.20240310
201-
# via inline-snapshot
202190
types-tqdm==4.66.0.20240417
203191
typing-extensions==4.12.2
204192
# via azure-core
205193
# via azure-identity
206-
# via black
207194
# via multidict
208195
# via mypy
209196
# via openai

tests/lib/chat/_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ def get_caller_name(*, stacklevel: int = 1) -> str:
5252
def clear_locals(string: str, *, stacklevel: int) -> str:
5353
caller = get_caller_name(stacklevel=stacklevel + 1)
5454
return string.replace(f"{caller}.<locals>.", "")
55+
56+
57+
def get_snapshot_value(snapshot: Any) -> Any:
58+
if not hasattr(snapshot, "_old_value"):
59+
return snapshot
60+
61+
old = snapshot._old_value
62+
if not hasattr(old, "value"):
63+
return old
64+
65+
loader = getattr(old.value, "_load_value", None)
66+
return loader() if loader else old.value

tests/lib/chat/test_completions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from openai._utils import assert_signatures_in_sync
1818
from openai._compat import PYDANTIC_V2
1919

20-
from ._utils import print_obj
20+
from ._utils import print_obj, get_snapshot_value
2121
from ...conftest import base_url
2222
from ..schema_types.query import Query
2323

@@ -1010,7 +1010,7 @@ def _on_response(response: httpx.Response) -> None:
10101010
respx_mock.post("/chat/completions").mock(
10111011
return_value=httpx.Response(
10121012
200,
1013-
content=content_snapshot._old_value,
1013+
content=get_snapshot_value(content_snapshot),
10141014
headers={"content-type": "application/json"},
10151015
)
10161016
)
@@ -1052,7 +1052,7 @@ async def _on_response(response: httpx.Response) -> None:
10521052
respx_mock.post("/chat/completions").mock(
10531053
return_value=httpx.Response(
10541054
200,
1055-
content=content_snapshot._old_value,
1055+
content=get_snapshot_value(content_snapshot),
10561056
headers={"content-type": "application/json"},
10571057
)
10581058
)

tests/lib/chat/test_completions_streaming.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
import pytest
1010
from respx import MockRouter
1111
from pydantic import BaseModel
12-
from inline_snapshot import external, snapshot, outsource
12+
from inline_snapshot import (
13+
external,
14+
snapshot,
15+
outsource, # pyright: ignore[reportUnknownVariableType]
16+
)
1317

1418
import openai
1519
from openai import OpenAI, AsyncOpenAI
@@ -26,7 +30,7 @@
2630
)
2731
from openai.lib._parsing._completions import ResponseFormatT
2832

29-
from ._utils import print_obj
33+
from ._utils import print_obj, get_snapshot_value
3034
from ...conftest import base_url
3135

3236
_T = TypeVar("_T")
@@ -1123,7 +1127,7 @@ def _on_response(response: httpx.Response) -> None:
11231127
respx_mock.post("/chat/completions").mock(
11241128
return_value=httpx.Response(
11251129
200,
1126-
content=content_snapshot._old_value._load_value(),
1130+
content=get_snapshot_value(content_snapshot),
11271131
headers={"content-type": "text/event-stream"},
11281132
)
11291133
)
@@ -1170,7 +1174,7 @@ def _on_response(response: httpx.Response) -> None:
11701174
respx_mock.post("/chat/completions").mock(
11711175
return_value=httpx.Response(
11721176
200,
1173-
content=content_snapshot._old_value._load_value(),
1177+
content=get_snapshot_value(content_snapshot),
11741178
headers={"content-type": "text/event-stream"},
11751179
)
11761180
)

0 commit comments

Comments
 (0)