From b6f232db1125045d79c444c736a2ae59c5501fdd Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sun, 6 Apr 2025 23:11:30 +0100 Subject: [PATCH] Addressed typing warnings from pyright --- src/microdot/test_client.py | 4 ++-- tests/test_microdot.py | 2 +- tests/test_websocket.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/microdot/test_client.py b/src/microdot/test_client.py index 1018f84..ec4109f 100644 --- a/src/microdot/test_client.py +++ b/src/microdot/test_client.py @@ -19,7 +19,7 @@ class TestResponse: #: explicitly sets it on the response object. self.reason = None #: A dictionary with the response headers. - self.headers = None + self.headers = {} #: The body of the response, as a bytes object. self.body = None #: The body of the response, decoded to a UTF-8 string. Set to @@ -195,7 +195,7 @@ class TestClient: ('127.0.0.1', 1234)) res = await self.app.dispatch_request(req) if res == Response.already_handled: - return None + return TestResponse() res.complete() self._update_cookies(res) diff --git a/tests/test_microdot.py b/tests/test_microdot.py index 32b9466..71e0d26 100644 --- a/tests/test_microdot.py +++ b/tests/test_microdot.py @@ -771,7 +771,7 @@ class TestMicrodot(unittest.TestCase): client = TestClient(app) res = self._run(client.get('/')) - self.assertEqual(res, None) + self.assertEqual(res.body, None) def test_mount(self): subapp = Microdot() diff --git a/tests/test_websocket.py b/tests/test_websocket.py index 9c20682..92d3605 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -46,11 +46,11 @@ class TestWebSocket(unittest.TestCase): client = TestClient(app) res = self._run(client.websocket('/echo', ws)) - self.assertIsNone(res) + self.assertIsNone(res.body) self.assertEqual(results, ['hello', b'bye', b'*' * 300, b'+' * 65537]) res = self._run(client.websocket('/divzero', ws)) - self.assertIsNone(res) + self.assertIsNone(res.body) WebSocket.max_message_length = -1 @unittest.skipIf(sys.implementation.name == 'micropython', @@ -74,7 +74,7 @@ class TestWebSocket(unittest.TestCase): client = TestClient(app) res = self._run(client.websocket('/echo', ws)) - self.assertIsNone(res) + self.assertIsNone(res.body) self.assertEqual(results, []) Request.max_body_length = saved_max_body_length