Skip to content

Commit

Permalink
aiohttp response binary format support
Browse files Browse the repository at this point in the history
  • Loading branch information
p1c2u committed Sep 20, 2023
1 parent cbbe084 commit 46c4477
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 4 additions & 1 deletion openapi_core/contrib/aiohttp/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def data(self) -> str:
if self.response.body is None:
return ""
if isinstance(self.response.body, bytes):
return self.response.body.decode("utf-8")
try:
return self.response.body.decode("utf-8")
except UnicodeDecodeError:
return self.response.body
assert isinstance(self.response.body, str)
return self.response.body

Expand Down
4 changes: 0 additions & 4 deletions tests/integration/contrib/aiohttp/test_aiohttp_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ def api_key_encoded(self):


class TestPetPhotoView(BaseTestPetstore):
@pytest.mark.xfail(
reason="response binary format not supported",
strict=True,
)
async def test_get_valid(self, client, data_gif):
headers = {
"Authorization": "Basic testuser",
Expand Down

0 comments on commit 46c4477

Please sign in to comment.