From 07241b226ee752b0c213d1e7d70d7fd6cc7e52f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 6 Sep 2022 18:48:37 +0200 Subject: [PATCH] trivial: use urllib.parse (#68784) --- fargo/utils.py | 9 +++++---- tests/test_public.py | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fargo/utils.py b/fargo/utils.py index 7582341..180e0f7 100644 --- a/fargo/utils.py +++ b/fargo/utils.py @@ -14,19 +14,20 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import urllib.parse + from django.utils.http import urlencode -from django.utils.six.moves.urllib import parse as urlparse def make_url(__url, **kwargs): request = kwargs.pop('request', None) - parsed = urlparse.urlparse(__url) - query = urlparse.parse_qs(parsed.query) + parsed = urllib.parse.urlparse(__url) + query = urllib.parse.parse_qs(parsed.query) for key, value in kwargs.items(): if value is not None: query[key] = value parsed = parsed[:4] + (urlencode(query),) + parsed[5:] - url = urlparse.urlunparse(parsed) + url = urllib.parse.urlunparse(parsed) if request: return request.build_absolute_uri(url) return url diff --git a/tests/test_public.py b/tests/test_public.py index 5badd34..3a96ace 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -15,10 +15,11 @@ # along with this program. If not, see . +import urllib.parse + import pytest from django.test import override_settings from django.urls import reverse -from django.utils.six.moves.urllib import parse as urlparse from webtest import Upload try: @@ -34,7 +35,7 @@ pytestmark = pytest.mark.django_db def test_unlogged(app): - assert urlparse.urlparse(app.get('/', status=302).location).path == '/login/' + assert urllib.parse.urlparse(app.get('/', status=302).location).path == '/login/' def test_upload(app, john_doe):