Skip to content

Commit be978d2

Browse files
committed
chore(internal): cast type in mocked test (openai#1112)
1 parent 15eb80c commit be978d2

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

tests/test_client.py

+44-32
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,17 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No
701701
with pytest.raises(APITimeoutError):
702702
self.client.post(
703703
"/chat/completions",
704-
body=dict(
705-
messages=[
706-
{
707-
"role": "user",
708-
"content": "Say this is a test",
709-
}
710-
],
711-
model="gpt-3.5-turbo",
704+
body=cast(
705+
object,
706+
dict(
707+
messages=[
708+
{
709+
"role": "user",
710+
"content": "Say this is a test",
711+
}
712+
],
713+
model="gpt-3.5-turbo",
714+
),
712715
),
713716
cast_to=httpx.Response,
714717
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
@@ -724,14 +727,17 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non
724727
with pytest.raises(APIStatusError):
725728
self.client.post(
726729
"/chat/completions",
727-
body=dict(
728-
messages=[
729-
{
730-
"role": "user",
731-
"content": "Say this is a test",
732-
}
733-
],
734-
model="gpt-3.5-turbo",
730+
body=cast(
731+
object,
732+
dict(
733+
messages=[
734+
{
735+
"role": "user",
736+
"content": "Say this is a test",
737+
}
738+
],
739+
model="gpt-3.5-turbo",
740+
),
735741
),
736742
cast_to=httpx.Response,
737743
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
@@ -1410,14 +1416,17 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter)
14101416
with pytest.raises(APITimeoutError):
14111417
await self.client.post(
14121418
"/chat/completions",
1413-
body=dict(
1414-
messages=[
1415-
{
1416-
"role": "user",
1417-
"content": "Say this is a test",
1418-
}
1419-
],
1420-
model="gpt-3.5-turbo",
1419+
body=cast(
1420+
object,
1421+
dict(
1422+
messages=[
1423+
{
1424+
"role": "user",
1425+
"content": "Say this is a test",
1426+
}
1427+
],
1428+
model="gpt-3.5-turbo",
1429+
),
14211430
),
14221431
cast_to=httpx.Response,
14231432
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
@@ -1433,14 +1442,17 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter)
14331442
with pytest.raises(APIStatusError):
14341443
await self.client.post(
14351444
"/chat/completions",
1436-
body=dict(
1437-
messages=[
1438-
{
1439-
"role": "user",
1440-
"content": "Say this is a test",
1441-
}
1442-
],
1443-
model="gpt-3.5-turbo",
1445+
body=cast(
1446+
object,
1447+
dict(
1448+
messages=[
1449+
{
1450+
"role": "user",
1451+
"content": "Say this is a test",
1452+
}
1453+
],
1454+
model="gpt-3.5-turbo",
1455+
),
14441456
),
14451457
cast_to=httpx.Response,
14461458
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},

0 commit comments

Comments
 (0)