Skip to content

Commit 9c8f082

Browse files
authored
Merge pull request #681 from python-openapi/fix/starlette-binary-request-test-fix
Starlette binary request test fix
2 parents 1eff5a2 + 1384e55 commit 9c8f082

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

tests/integration/contrib/starlette/data/v3.0/starletteproject/pets/endpoints.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ def pet_photo_endpoint(request):
2626
if request.method == "GET":
2727
response = StreamingResponse([OPENID_LOGO], media_type="image/gif")
2828
elif request.method == "POST":
29-
with request.form() as form:
30-
filename = form["file"].filename
31-
contents = form["file"].read()
32-
response = Response(status_code=201)
29+
contents = request.body()
30+
response = Response(status_code=201)
3331
openapi_response = StarletteOpenAPIResponse(response)
3432
response_unmarshalled = unmarshal_response(
3533
openapi_request, openapi_response, spec=spec

tests/integration/contrib/starlette/test_starlette_project.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,12 @@ def test_post_valid(self, client, data_gif):
6969
"Api-Key": self.api_key_encoded,
7070
"Content-Type": content_type,
7171
}
72-
data = {
73-
"file": data_gif,
74-
}
7572

7673
cookies = {"user": "1"}
7774
response = client.post(
7875
"/v1/pets/1/photo",
7976
headers=headers,
80-
data=data,
77+
data=data_gif,
8178
cookies=cookies,
8279
)
8380

0 commit comments

Comments
 (0)