diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-09-05 14:38:59 -0500 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-09-10 21:29:31 +0200 |
| commit | f9f792eb04dfd48d93682070583f473166b490ae (patch) | |
| tree | c66c3d474e808d664b3b24b94fdc3d5344295c4f /tests | |
| parent | 960f5bc75901f76e9b4b356f98b22b494fb47611 (diff) | |
[1.6.x] Took advantage of django.utils.six.moves.urllib.*.
Backport of 6a6428a36 from master.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_views/tests.py | 11 | ||||
| -rw-r--r-- | tests/file_storage/tests.py | 7 | ||||
| -rw-r--r-- | tests/requests/tests.py | 4 | ||||
| -rw-r--r-- | tests/servers/tests.py | 6 | ||||
| -rw-r--r-- | tests/template_tests/tests.py | 5 | ||||
| -rw-r--r-- | tests/test_client/views.py | 5 |
6 files changed, 13 insertions, 25 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 28dea38cfd..2ec5c87949 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -4,10 +4,6 @@ from __future__ import absolute_import, unicode_literals import os import re import datetime -try: - from urllib.parse import urljoin -except ImportError: # Python 2 - from urlparse import urljoin from django.conf import settings, global_settings from django.core import mail @@ -30,14 +26,17 @@ from django.forms.util import ErrorList from django.template.response import TemplateResponse from django.test import TestCase from django.test.utils import patch_logger -from django.utils import formats, translation, unittest +from django.test.utils import override_settings +from django.utils import formats +from django.utils import translation +from django.utils import unittest from django.utils.cache import get_max_age from django.utils.encoding import iri_to_uri, force_bytes from django.utils.html import escape from django.utils.http import urlencode, urlquote +from django.utils.six.moves.urllib.parse import urljoin from django.utils._os import upath from django.utils import six -from django.test.utils import override_settings # local test models from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount, diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index e6caabf9d9..f92eae3f53 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -7,10 +7,6 @@ import shutil import sys import tempfile import time -try: - from urllib.request import urlopen -except ImportError: # Python 2 - from urllib2 import urlopen import zlib from datetime import datetime, timedelta from io import BytesIO @@ -27,10 +23,11 @@ from django.core.files.images import get_image_dimensions from django.core.files.storage import FileSystemStorage, get_storage_class from django.core.files.uploadedfile import UploadedFile from django.test import LiveServerTestCase, SimpleTestCase +from django.test.utils import override_settings from django.utils import six from django.utils import unittest +from django.utils.six.moves.urllib.request import urlopen from django.utils._os import upath -from django.test.utils import override_settings try: from django.utils.image import Image diff --git a/tests/requests/tests.py b/tests/requests/tests.py index 9e1cf19307..98cda31c1b 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -17,6 +17,7 @@ from django.test.utils import override_settings, str_prefix from django.utils import six from django.utils.unittest import skipIf from django.utils.http import cookie_date, urlencode +from django.utils.six.moves.urllib.parse import urlencode as original_urlencode from django.utils.timezone import utc @@ -493,8 +494,7 @@ class RequestsTests(SimpleTestCase): """ Test a POST with non-utf-8 payload encoding. """ - from django.utils.http import urllib_parse - payload = FakePayload(urllib_parse.urlencode({'key': 'España'.encode('latin-1')})) + payload = FakePayload(original_urlencode({'key': 'España'.encode('latin-1')})) request = WSGIRequest({ 'REQUEST_METHOD': 'POST', 'CONTENT_LENGTH': len(payload), diff --git a/tests/servers/tests.py b/tests/servers/tests.py index be74afe820..caa2ddb084 100644 --- a/tests/servers/tests.py +++ b/tests/servers/tests.py @@ -5,16 +5,14 @@ Tests for django.core.servers. from __future__ import unicode_literals import os -try: - from urllib.request import urlopen, HTTPError -except ImportError: # Python 2 - from urllib2 import urlopen, HTTPError from django.core.exceptions import ImproperlyConfigured from django.test import LiveServerTestCase from django.core.servers.basehttp import WSGIServerException from django.test.utils import override_settings from django.utils.http import urlencode +from django.utils.six.moves.urllib.error import HTTPError +from django.utils.six.moves.urllib.request import urlopen from django.utils._os import upath from .models import Person diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 76712a09a6..b2f35b1a8d 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -13,10 +13,6 @@ import time import os import sys import traceback -try: - from urllib.parse import urljoin -except ImportError: # Python 2 - from urlparse import urljoin import warnings from django import template @@ -34,6 +30,7 @@ from django.utils._os import upath from django.utils.translation import activate, deactivate, ugettext as _ from django.utils.safestring import mark_safe from django.utils import six +from django.utils.six.moves.urllib.parse import urljoin from django.utils.tzinfo import LocalTimezone from i18n import TransRealMixin diff --git a/tests/test_client/views.py b/tests/test_client/views.py index 76296cb80d..08cdd8c198 100644 --- a/tests/test_client/views.py +++ b/tests/test_client/views.py @@ -1,7 +1,3 @@ -try: - from urllib.parse import urlencode -except ImportError: # Python 2 - from urllib import urlencode from xml.dom.minidom import parseString from django.contrib.auth.decorators import login_required, permission_required @@ -13,6 +9,7 @@ from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound from django.shortcuts import render_to_response from django.template import Context, Template from django.utils.decorators import method_decorator +from django.utils.six.moves.urllib.parse import urlencode def get_view(request): "A simple view that expects a GET request, and returns a rendered template" |
