Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aiohttp response binary format support #675

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading