summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-09-05 14:38:59 -0500
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-09-05 14:39:23 -0500
commit6a6428a36f221446b17eaf4876e92d3db1781962 (patch)
treea57290e315203b770a56b0d4691ee2d4d104cccc /tests
parented9cd4fd8b425ab5010b27aefc7ef6e50d55fb54 (diff)
Took advantage of django.utils.six.moves.urllib.*.
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_views/tests.py7
-rw-r--r--tests/file_storage/tests.py7
-rw-r--r--tests/requests/tests.py4
-rw-r--r--tests/servers/tests.py6
-rw-r--r--tests/staticfiles_tests/test_liveserver.py5
-rw-r--r--tests/template_tests/tests.py5
-rw-r--r--tests/test_client/views.py5
7 files changed, 11 insertions, 28 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index d7b6570f10..091ce084c8 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -5,10 +5,6 @@ import os
import re
import datetime
import unittest
-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,15 +26,16 @@ 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.test.utils import override_settings
from django.utils import formats
from django.utils import translation
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 c09d0ef239..bd9510e698 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -8,10 +8,6 @@ import sys
import tempfile
import time
import unittest
-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
@@ -28,9 +24,10 @@ 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.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 5bd3e5141f..b5edc09deb 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -18,6 +18,7 @@ from django.test.client import FakePayload
from django.test.utils import override_settings, str_prefix
from django.utils import six
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
@@ -279,8 +280,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 86b8a4c6c9..f833570862 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/staticfiles_tests/test_liveserver.py b/tests/staticfiles_tests/test_liveserver.py
index 80333aae1f..71f4bb89a1 100644
--- a/tests/staticfiles_tests/test_liveserver.py
+++ b/tests/staticfiles_tests/test_liveserver.py
@@ -5,13 +5,10 @@ django.test.LiveServerTestCase.
"""
import os
-try:
- from urllib.request import urlopen
-except ImportError: # Python 2
- from urllib2 import urlopen
from django.core.exceptions import ImproperlyConfigured
from django.test.utils import override_settings
+from django.utils.six.moves.urllib.request import urlopen
from django.utils._os import upath
from django.contrib.staticfiles.testing import StaticLiveServerCase
diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py
index 876fb448f5..5897a3e83a 100644
--- a/tests/template_tests/tests.py
+++ b/tests/template_tests/tests.py
@@ -13,10 +13,6 @@ import os
import sys
import traceback
import unittest
-try:
- from urllib.parse import urljoin
-except ImportError: # Python 2
- from urlparse import urljoin
import warnings
from django import template
@@ -33,6 +29,7 @@ from django.utils._os import upath
from django.utils.translation import activate, deactivate
from django.utils.safestring import mark_safe
from django.utils import six
+from django.utils.six.moves.urllib.parse import urljoin
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"