summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2024-04-05 10:24:36 +0200
committerCarlton Gibson <carlton.gibson@noumenal.es>2024-04-05 11:35:38 +0200
commitbcd255cd5ca0a1e686d276cca71f45ec400d84a2 (patch)
tree1e3e582e6f797ae21cf9e2670972156f712ca65f /tests
parent4d2ef9bb826db76acb5ed7609a9162de9b651921 (diff)
Fixed #35354 -- Simplified ASGIRequest path handling.
Following the ASGI HTTP Connection Scope docs[0], the provided `path` is already the correct value that Django requires. In combination with `root_path`, from which `script_name` is derived, the `path_info` variable is set. It's then redundant to re-calculate `path` from `script_name` and `path_info`. See also, a clarifying discussion on the ASGIref repo[1]. [0]: https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope [1]: https://github.com/django/asgiref/issues/424
Diffstat (limited to 'tests')
-rw-r--r--tests/handlers/tests.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py
index 959e4737d2..ffa362abdd 100644
--- a/tests/handlers/tests.py
+++ b/tests/handlers/tests.py
@@ -335,11 +335,13 @@ class AsyncHandlerRequestTests(SimpleTestCase):
self.assertEqual(request.script_name, "/root")
self.assertEqual(request.path_info, "/somepath/")
- @override_settings(FORCE_SCRIPT_NAME="/FORCED_PREFIX/")
+ @override_settings(FORCE_SCRIPT_NAME="/FORCED_PREFIX")
def test_force_script_name(self):
async_request_factory = AsyncRequestFactory()
- request = async_request_factory.request(**{"path": "/somepath/"})
+ request = async_request_factory.request(**{"path": "/FORCED_PREFIX/somepath/"})
self.assertEqual(request.path, "/FORCED_PREFIX/somepath/")
+ self.assertEqual(request.script_name, "/FORCED_PREFIX")
+ self.assertEqual(request.path_info, "/somepath/")
async def test_sync_streaming(self):
response = await self.async_client.get("/streaming/")