From ff308a06047cd60806d604a7cf612e5656ee2ac9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 29 May 2024 14:48:27 +0100 Subject: Fixed 35467 -- Replaced urlparse with urlsplit where appropriate. This work should not generate any change of functionality, and `urlsplit` is approximately 6x faster. Most use cases of `urlparse` didn't touch the path, so they can be converted to `urlsplit` without any issue. Most of those which do use `.path`, simply parse the URL, mutate the querystring, then put them back together, which is also fine (so long as urlunsplit is used). --- tests/admin_views/tests.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/admin_views') diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index d49e7d028b..cb6815e7a8 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -4,7 +4,7 @@ import re import unittest import zoneinfo from unittest import mock -from urllib.parse import parse_qsl, urljoin, urlparse +from urllib.parse import parse_qsl, urljoin, urlsplit from django import forms from django.contrib import admin @@ -357,7 +357,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): **save_option, }, ) - parsed_url = urlparse(response.url) + parsed_url = urlsplit(response.url) self.assertEqual(parsed_url.query, qsl) def test_change_query_string_persists(self): @@ -386,7 +386,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): **save_option, }, ) - parsed_url = urlparse(response.url) + parsed_url = urlsplit(response.url) self.assertEqual(parsed_url.query, qsl) def test_basic_edit_GET(self): @@ -8032,11 +8032,11 @@ class AdminKeepChangeListFiltersTests(TestCase): Assert that two URLs are equal despite the ordering of their querystring. Refs #22360. """ - parsed_url1 = urlparse(url1) + parsed_url1 = urlsplit(url1) path1 = parsed_url1.path parsed_qs1 = dict(parse_qsl(parsed_url1.query)) - parsed_url2 = urlparse(url2) + parsed_url2 = urlsplit(url2) path2 = parsed_url2.path parsed_qs2 = dict(parse_qsl(parsed_url2.query)) -- cgit v1.3