From 249309d61cd78c7eaa990a86339168ef21e2ad69 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Sat, 21 Feb 2026 17:24:09 -0800 Subject: [PATCH] fix(tests): add .state to MockRequest in http_parsing_utils tests MockRequest mocks were missing .state attribute, causing _read_request_body to hit AttributeError before reading the body and silently return {} via the catch-all handler. --- tests/local_testing/test_http_parsing_utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/local_testing/test_http_parsing_utils.py b/tests/local_testing/test_http_parsing_utils.py index 813460c7e27..4c28f9d9c10 100644 --- a/tests/local_testing/test_http_parsing_utils.py +++ b/tests/local_testing/test_http_parsing_utils.py @@ -19,6 +19,9 @@ async def test_read_request_body_valid_json(): """Test the function with a valid JSON payload.""" class MockRequest: + def __init__(self): + self.state = type("State", (), {})() + async def body(self): return b'{"key": "value"}' @@ -32,6 +35,9 @@ async def test_read_request_body_empty_body(): """Test the function with an empty body.""" class MockRequest: + def __init__(self): + self.state = type("State", (), {})() + async def body(self): return b"" @@ -45,6 +51,9 @@ async def test_read_request_body_invalid_json(): """Test the function with an invalid JSON payload.""" class MockRequest: + def __init__(self): + self.state = type("State", (), {})() + async def body(self): return b'{"key": value}' # Missing quotes around `value` @@ -59,6 +68,9 @@ async def test_read_request_body_large_payload(): large_payload = '{"key":' + '"a"' * 10**6 + "}" # Large payload class MockRequest: + def __init__(self): + self.state = type("State", (), {})() + async def body(self): return large_payload.encode() @@ -72,6 +84,9 @@ async def test_read_request_body_unexpected_error(): """Test the function when an unexpected error occurs.""" class MockRequest: + def __init__(self): + self.state = type("State", (), {})() + async def body(self): raise ValueError("Unexpected error")