diff --git a/tests/test_asgi_compliance.py b/tests/test_asgi_compliance.py index 9bacfddb..5e97ad0e 100644 --- a/tests/test_asgi_compliance.py +++ b/tests/test_asgi_compliance.py @@ -38,7 +38,9 @@ class TestASGIVersion: """Create a mock HTTP request.""" request = mock.Mock() request.method = kwargs.get("method", "GET") - request.path = kwargs.get("path", "/") + path = kwargs.get("path", "/") + request.path = path + request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"") request.query = kwargs.get("query", "") request.version = kwargs.get("version", (1, 1)) request.scheme = kwargs.get("scheme", "http") @@ -137,7 +139,9 @@ class TestHTTPScopeKeys: """Create a mock HTTP request.""" request = mock.Mock() request.method = kwargs.get("method", "GET") - request.path = kwargs.get("path", "/") + path = kwargs.get("path", "/") + request.path = path + request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"") request.query = kwargs.get("query", "") request.version = kwargs.get("version", (1, 1)) request.scheme = kwargs.get("scheme", "http") @@ -654,6 +658,7 @@ class TestStateSharing: request = mock.Mock() request.method = "GET" request.path = "/" + request.raw_path = b"/" request.query = "" request.version = (1, 1) request.scheme = "http" diff --git a/tests/test_asgi_http_scope.py b/tests/test_asgi_http_scope.py index 545d0be3..84827239 100644 --- a/tests/test_asgi_http_scope.py +++ b/tests/test_asgi_http_scope.py @@ -39,7 +39,9 @@ class TestHTTPScopeBuilding: """Create a mock HTTP request.""" request = mock.Mock() request.method = kwargs.get("method", "GET") - request.path = kwargs.get("path", "/") + path = kwargs.get("path", "/") + request.path = path + request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"") request.query = kwargs.get("query", "") request.version = kwargs.get("version", (1, 1)) request.scheme = kwargs.get("scheme", "http") @@ -113,7 +115,9 @@ class TestPathHandling: """Create a mock HTTP request.""" request = mock.Mock() request.method = kwargs.get("method", "GET") - request.path = kwargs.get("path", "/") + path = kwargs.get("path", "/") + request.path = path + request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"") request.query = kwargs.get("query", "") request.version = kwargs.get("version", (1, 1)) request.scheme = kwargs.get("scheme", "http") @@ -193,7 +197,9 @@ class TestQueryStringHandling: """Create a mock HTTP request.""" request = mock.Mock() request.method = kwargs.get("method", "GET") - request.path = kwargs.get("path", "/") + path = kwargs.get("path", "/") + request.path = path + request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"") request.query = kwargs.get("query", "") request.version = kwargs.get("version", (1, 1)) request.scheme = kwargs.get("scheme", "http") @@ -269,7 +275,9 @@ class TestHeaderHandling: """Create a mock HTTP request.""" request = mock.Mock() request.method = kwargs.get("method", "GET") - request.path = kwargs.get("path", "/") + path = kwargs.get("path", "/") + request.path = path + request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"") request.query = kwargs.get("query", "") request.version = kwargs.get("version", (1, 1)) request.scheme = kwargs.get("scheme", "http") @@ -361,7 +369,9 @@ class TestWebSocketScope: """Create a mock WebSocket upgrade request.""" request = mock.Mock() request.method = "GET" - request.path = kwargs.get("path", "/ws") + path = kwargs.get("path", "/ws") + request.path = path + request.raw_path = kwargs.get("raw_path", path.encode("latin-1") if path else b"") request.query = kwargs.get("query", "") request.version = kwargs.get("version", (1, 1)) request.scheme = kwargs.get("scheme", "http") @@ -574,6 +584,7 @@ class TestAddressHandling: request = mock.Mock() request.method = "GET" request.path = "/" + request.raw_path = b"/" request.query = "" request.version = (1, 1) request.scheme = "http" diff --git a/tests/test_asgi_worker.py b/tests/test_asgi_worker.py index 1217c1bf..f52c1726 100644 --- a/tests/test_asgi_worker.py +++ b/tests/test_asgi_worker.py @@ -724,10 +724,11 @@ class TestASGIHTTP2Priority: protocol = ASGIProtocol(worker) # Create mock HTTP/1.1 request (no priority attributes) - request = mock.Mock(spec=['method', 'path', 'query', 'version', + request = mock.Mock(spec=['method', 'path', 'raw_path', 'query', 'version', 'scheme', 'headers']) request.method = "GET" request.path = "/test" + request.raw_path = b"/test" request.query = "" request.version = (1, 1) request.scheme = "http"