From 9c86b93886b875e61a10df6a90f568b7e335a6ed Mon Sep 17 00:00:00 2001 From: Dave Tapley Date: Thu, 1 Feb 2024 17:50:21 +0000 Subject: [PATCH] TestClient methods return Result, not _ResultBase Fixes https://github.com/falconry/falcon/issues/2207 --- falcon/testing/client.py | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/falcon/testing/client.py b/falcon/testing/client.py index fce0f4d0a..87e91a9c5 100644 --- a/falcon/testing/client.py +++ b/falcon/testing/client.py @@ -451,7 +451,7 @@ def simulate_request( cookies=None, asgi_chunk_size=4096, asgi_disconnect_ttl=300, -) -> _ResultBase: +) -> Result: """Simulate a request to a WSGI or ASGI application. @@ -1038,7 +1038,7 @@ async def __aexit__(self, ex_type, ex, tb): return True - async def simulate_get(self, path='/', **kwargs) -> _ResultBase: + async def simulate_get(self, path='/', **kwargs) -> Result: """Simulate a GET request to an ASGI application. (See also: :py:meth:`falcon.testing.simulate_get`) @@ -1107,49 +1107,49 @@ def simulate_ws(self, path='/', **kwargs): return _WSContextManager(ws, task_req) - async def simulate_head(self, path='/', **kwargs) -> _ResultBase: + async def simulate_head(self, path='/', **kwargs) -> Result: """Simulate a HEAD request to an ASGI application. (See also: :py:meth:`falcon.testing.simulate_head`) """ return await self.simulate_request('HEAD', path, **kwargs) - async def simulate_post(self, path='/', **kwargs) -> _ResultBase: + async def simulate_post(self, path='/', **kwargs) -> Result: """Simulate a POST request to an ASGI application. (See also: :py:meth:`falcon.testing.simulate_post`) """ return await self.simulate_request('POST', path, **kwargs) - async def simulate_put(self, path='/', **kwargs) -> _ResultBase: + async def simulate_put(self, path='/', **kwargs) -> Result: """Simulate a PUT request to an ASGI application. (See also: :py:meth:`falcon.testing.simulate_put`) """ return await self.simulate_request('PUT', path, **kwargs) - async def simulate_options(self, path='/', **kwargs) -> _ResultBase: + async def simulate_options(self, path='/', **kwargs) -> Result: """Simulate an OPTIONS request to an ASGI application. (See also: :py:meth:`falcon.testing.simulate_options`) """ return await self.simulate_request('OPTIONS', path, **kwargs) - async def simulate_patch(self, path='/', **kwargs) -> _ResultBase: + async def simulate_patch(self, path='/', **kwargs) -> Result: """Simulate a PATCH request to an ASGI application. (See also: :py:meth:`falcon.testing.simulate_patch`) """ return await self.simulate_request('PATCH', path, **kwargs) - async def simulate_delete(self, path='/', **kwargs) -> _ResultBase: + async def simulate_delete(self, path='/', **kwargs) -> Result: """Simulate a DELETE request to an ASGI application. (See also: :py:meth:`falcon.testing.simulate_delete`) """ return await self.simulate_request('DELETE', path, **kwargs) - async def simulate_request(self, *args, **kwargs) -> _ResultBase: + async def simulate_request(self, *args, **kwargs) -> Result: """Simulate a request to an ASGI application. Wraps :py:meth:`falcon.testing.simulate_request` to perform a @@ -1185,7 +1185,7 @@ async def simulate_request(self, *args, **kwargs) -> _ResultBase: websocket = _simulate_method_alias(simulate_ws, replace_name='websocket') -def simulate_get(app, path, **kwargs) -> _ResultBase: +def simulate_get(app, path, **kwargs) -> Result: """Simulate a GET request to a WSGI or ASGI application. Equivalent to:: @@ -1288,7 +1288,7 @@ def simulate_get(app, path, **kwargs) -> _ResultBase: return simulate_request(app, 'GET', path, **kwargs) -def simulate_head(app, path, **kwargs) -> _ResultBase: +def simulate_head(app, path, **kwargs) -> Result: """Simulate a HEAD request to a WSGI or ASGI application. Equivalent to:: @@ -1385,7 +1385,7 @@ def simulate_head(app, path, **kwargs) -> _ResultBase: return simulate_request(app, 'HEAD', path, **kwargs) -def simulate_post(app, path, **kwargs) -> _ResultBase: +def simulate_post(app, path, **kwargs) -> Result: """Simulate a POST request to a WSGI or ASGI application. Equivalent to:: @@ -1496,7 +1496,7 @@ def simulate_post(app, path, **kwargs) -> _ResultBase: return simulate_request(app, 'POST', path, **kwargs) -def simulate_put(app, path, **kwargs) -> _ResultBase: +def simulate_put(app, path, **kwargs) -> Result: """Simulate a PUT request to a WSGI or ASGI application. Equivalent to:: @@ -1607,7 +1607,7 @@ def simulate_put(app, path, **kwargs) -> _ResultBase: return simulate_request(app, 'PUT', path, **kwargs) -def simulate_options(app, path, **kwargs) -> _ResultBase: +def simulate_options(app, path, **kwargs) -> Result: """Simulate an OPTIONS request to a WSGI or ASGI application. Equivalent to:: @@ -1696,7 +1696,7 @@ def simulate_options(app, path, **kwargs) -> _ResultBase: return simulate_request(app, 'OPTIONS', path, **kwargs) -def simulate_patch(app, path, **kwargs) -> _ResultBase: +def simulate_patch(app, path, **kwargs) -> Result: """Simulate a PATCH request to a WSGI or ASGI application. Equivalent to:: @@ -1802,7 +1802,7 @@ def simulate_patch(app, path, **kwargs) -> _ResultBase: return simulate_request(app, 'PATCH', path, **kwargs) -def simulate_delete(app, path, **kwargs) -> _ResultBase: +def simulate_delete(app, path, **kwargs) -> Result: """Simulate a DELETE request to a WSGI or ASGI application. Equivalent to:: @@ -2002,56 +2002,56 @@ async def __aexit__(self, ex_type, ex, tb): return result - def simulate_get(self, path='/', **kwargs) -> _ResultBase: + def simulate_get(self, path='/', **kwargs) -> Result: """Simulate a GET request to a WSGI application. (See also: :py:meth:`falcon.testing.simulate_get`) """ return self.simulate_request('GET', path, **kwargs) - def simulate_head(self, path='/', **kwargs) -> _ResultBase: + def simulate_head(self, path='/', **kwargs) -> Result: """Simulate a HEAD request to a WSGI application. (See also: :py:meth:`falcon.testing.simulate_head`) """ return self.simulate_request('HEAD', path, **kwargs) - def simulate_post(self, path='/', **kwargs) -> _ResultBase: + def simulate_post(self, path='/', **kwargs) -> Result: """Simulate a POST request to a WSGI application. (See also: :py:meth:`falcon.testing.simulate_post`) """ return self.simulate_request('POST', path, **kwargs) - def simulate_put(self, path='/', **kwargs) -> _ResultBase: + def simulate_put(self, path='/', **kwargs) -> Result: """Simulate a PUT request to a WSGI application. (See also: :py:meth:`falcon.testing.simulate_put`) """ return self.simulate_request('PUT', path, **kwargs) - def simulate_options(self, path='/', **kwargs) -> _ResultBase: + def simulate_options(self, path='/', **kwargs) -> Result: """Simulate an OPTIONS request to a WSGI application. (See also: :py:meth:`falcon.testing.simulate_options`) """ return self.simulate_request('OPTIONS', path, **kwargs) - def simulate_patch(self, path='/', **kwargs) -> _ResultBase: + def simulate_patch(self, path='/', **kwargs) -> Result: """Simulate a PATCH request to a WSGI application. (See also: :py:meth:`falcon.testing.simulate_patch`) """ return self.simulate_request('PATCH', path, **kwargs) - def simulate_delete(self, path='/', **kwargs) -> _ResultBase: + def simulate_delete(self, path='/', **kwargs) -> Result: """Simulate a DELETE request to a WSGI application. (See also: :py:meth:`falcon.testing.simulate_delete`) """ return self.simulate_request('DELETE', path, **kwargs) - def simulate_request(self, *args, **kwargs) -> _ResultBase: + def simulate_request(self, *args, **kwargs) -> Result: """Simulate a request to a WSGI application. Wraps :py:meth:`falcon.testing.simulate_request` to perform a