diff --git a/pyramid_openapi3/tests/test_contenttypes.py b/pyramid_openapi3/tests/test_contenttypes.py index 2da62d6..cf6904b 100644 --- a/pyramid_openapi3/tests/test_contenttypes.py +++ b/pyramid_openapi3/tests/test_contenttypes.py @@ -72,9 +72,6 @@ def test_post_json(self) -> None: res = self._testapp().post_json("/foo", {"bar": "baz"}, status=200) self.assertEqual(res.json, {"bar": "zab"}) - # FIXME: Something deep in request validation isn't happy right now. - # Might be related: https://github.com/Pylons/pyramid_openapi3/issues/199 - @unittest.expectedFailure def test_post_form(self) -> None: # pragma: no cover """Post with `application/x-www-form-urlencoded`.""" diff --git a/pyramid_openapi3/tests/test_wrappers.py b/pyramid_openapi3/tests/test_wrappers.py index 56dafa8..a96de65 100644 --- a/pyramid_openapi3/tests/test_wrappers.py +++ b/pyramid_openapi3/tests/test_wrappers.py @@ -72,7 +72,7 @@ def test_relative_app_request() -> None: assert openapi_request.path == "/subpath/foo" assert openapi_request.path_pattern == "/foo" assert openapi_request.method == "get" - assert openapi_request.body == "" + assert openapi_request.body == b"" assert openapi_request.mimetype == "text/html" assert openapi_request.content_type == "text/html" @@ -114,7 +114,7 @@ def test_mapped_values_response() -> None: openapi_response = PyramidOpenAPIResponse(pyramid_request.response) - assert openapi_response.data == "" + assert openapi_response.data == b"" assert openapi_response.status_code == 200 assert openapi_response.mimetype == "text/html" assert openapi_response.content_type == "text/html" diff --git a/pyramid_openapi3/wrappers.py b/pyramid_openapi3/wrappers.py index 482e911..c69b052 100644 --- a/pyramid_openapi3/wrappers.py +++ b/pyramid_openapi3/wrappers.py @@ -47,12 +47,10 @@ def method(self) -> str: return self.request.method.lower() @property - def body(self) -> t.Optional[t.Union[str, t.Dict]]: - """The request body, as string.""" # noqa D401 + def body(self) -> t.Optional[t.Union[bytes, str, t.Dict]]: + """The request body.""" # noqa D401 if "multipart/form-data" == self.request.content_type: return self.request.POST.mixed() - if isinstance(self.request.body, bytes): - return self.request.body.decode("utf-8") return self.request.body @property @@ -71,9 +69,9 @@ def __init__(self, response: Response) -> None: self.response = response @property - def data(self) -> str: - """The response body, as string.""" # noqa D401 - return self.response.text + def data(self) -> bytes: + """The response body.""" # noqa D401 + return self.response.body @property def status_code(self) -> int: