summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-02-17 19:45:34 -0500
committerTim Graham <timograham@gmail.com>2017-09-25 17:11:03 -0400
commitcfff2af02be40106d4759cc6f8bfa476ce82421c (patch)
tree2680ff4040dd83d7b50ca2265e8268e362142476 /tests
parenta80903b7114c984b5087597e8c34750e7bb44f51 (diff)
Fixed #27857 -- Dropped support for Python 3.4.
Diffstat (limited to 'tests')
-rw-r--r--tests/handlers/tests.py8
-rw-r--r--tests/handlers/views.py7
-rw-r--r--tests/mail/tests.py9
-rw-r--r--tests/servers/tests.py7
-rw-r--r--tests/sessions_tests/tests.py7
-rw-r--r--tests/test_runner/test_debug_sql.py20
-rw-r--r--tests/test_utils/tests.py4
7 files changed, 15 insertions, 47 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py
index 167faadb02..adf34c5437 100644
--- a/tests/handlers/tests.py
+++ b/tests/handlers/tests.py
@@ -1,5 +1,3 @@
-import unittest
-
from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest, get_script_name
from django.core.signals import request_finished, request_started
@@ -8,11 +6,6 @@ from django.test import (
RequestFactory, SimpleTestCase, TransactionTestCase, override_settings,
)
-try:
- from http import HTTPStatus
-except ImportError: # Python < 3.5
- HTTPStatus = None
-
class HandlerTests(SimpleTestCase):
@@ -182,7 +175,6 @@ class HandlerRequestTests(SimpleTestCase):
environ = RequestFactory().get('/%E2%A8%87%87%A5%E2%A8%A0').environ
self.assertIsInstance(environ['PATH_INFO'], str)
- @unittest.skipIf(HTTPStatus is None, 'HTTPStatus only exists on Python 3.5+')
def test_handle_accepts_httpstatus_enum_value(self):
def start_response(status, headers):
start_response.status = status
diff --git a/tests/handlers/views.py b/tests/handlers/views.py
index 22b94de3b9..8005cc605f 100644
--- a/tests/handlers/views.py
+++ b/tests/handlers/views.py
@@ -1,13 +1,10 @@
+from http import HTTPStatus
+
from django.core.exceptions import SuspiciousOperation
from django.db import connection, transaction
from django.http import HttpResponse, StreamingHttpResponse
from django.views.decorators.csrf import csrf_exempt
-try:
- from http import HTTPStatus
-except ImportError: # Python < 3.5
- pass
-
def regular(request):
return HttpResponse(b"regular content")
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 29a56d6e74..b60e7ff6c9 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -61,10 +61,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
def iter_attachments():
for i in email_message.walk():
- # Once support for Python<3.5 has been dropped, we can use
- # i.get_content_disposition() here instead.
- content_disposition = i.get('content-disposition', '').split(';')[0].lower()
- if content_disposition == 'attachment':
+ if i.get_content_disposition() == 'attachment':
filename = i.get_filename()
content = i.get_payload(decode=True)
mimetype = i.get_content_type()
@@ -1161,8 +1158,8 @@ class FakeSMTPServer(smtpd.SMTPServer, threading.Thread):
def __init__(self, *args, **kwargs):
threading.Thread.__init__(self)
# New kwarg added in Python 3.5; default switching to False in 3.6.
- if sys.version_info >= (3, 5):
- kwargs['decode_data'] = True
+ # Setting a value only silences a deprecation warning in Python 3.5.
+ kwargs['decode_data'] = True
smtpd.SMTPServer.__init__(self, *args, **kwargs)
self._sink = []
self.active = False
diff --git a/tests/servers/tests.py b/tests/servers/tests.py
index ea64c246e2..cbf477fa98 100644
--- a/tests/servers/tests.py
+++ b/tests/servers/tests.py
@@ -5,7 +5,7 @@ import errno
import os
import socket
import sys
-from http.client import HTTPConnection
+from http.client import HTTPConnection, RemoteDisconnected
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import urlopen
@@ -14,11 +14,6 @@ from django.test import LiveServerTestCase, override_settings
from .models import Person
-try:
- from http.client import RemoteDisconnected
-except ImportError: # Python 3.4
- from http.client import BadStatusLine as RemoteDisconnected
-
TEST_ROOT = os.path.dirname(__file__)
TEST_SETTINGS = {
'MEDIA_URL': '/media/',
diff --git a/tests/sessions_tests/tests.py b/tests/sessions_tests/tests.py
index bd0e3b7668..3a3af1613a 100644
--- a/tests/sessions_tests/tests.py
+++ b/tests/sessions_tests/tests.py
@@ -2,7 +2,6 @@ import base64
import os
import shutil
import string
-import sys
import tempfile
import unittest
from datetime import timedelta
@@ -733,10 +732,9 @@ class SessionMiddlewareTests(TestCase):
# A deleted cookie header looks like:
# Set-Cookie: sessionid=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
self.assertEqual(
- 'Set-Cookie: {}={}; expires=Thu, 01-Jan-1970 00:00:00 GMT; '
+ 'Set-Cookie: {}=""; expires=Thu, 01-Jan-1970 00:00:00 GMT; '
'Max-Age=0; Path=/'.format(
settings.SESSION_COOKIE_NAME,
- '""' if sys.version_info >= (3, 5) else '',
),
str(response.cookies[settings.SESSION_COOKIE_NAME])
)
@@ -763,10 +761,9 @@ class SessionMiddlewareTests(TestCase):
# expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0;
# Path=/example/
self.assertEqual(
- 'Set-Cookie: {}={}; Domain=.example.local; expires=Thu, '
+ 'Set-Cookie: {}=""; Domain=.example.local; expires=Thu, '
'01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/example/'.format(
settings.SESSION_COOKIE_NAME,
- '""' if sys.version_info >= (3, 5) else '',
),
str(response.cookies[settings.SESSION_COOKIE_NAME])
)
diff --git a/tests/test_runner/test_debug_sql.py b/tests/test_runner/test_debug_sql.py
index 2ac7203051..8c4cb6fef6 100644
--- a/tests/test_runner/test_debug_sql.py
+++ b/tests/test_runner/test_debug_sql.py
@@ -1,4 +1,3 @@
-import sys
import unittest
from io import StringIO
@@ -94,18 +93,13 @@ class TestDebugSQL(unittest.TestCase):
]
verbose_expected_outputs = [
- # Output format changed in Python 3.5+
- x.format('' if sys.version_info < (3, 5) else 'TestDebugSQL.') for x in [
- 'runTest (test_runner.test_debug_sql.{}FailingTest) ... FAIL',
- 'runTest (test_runner.test_debug_sql.{}ErrorTest) ... ERROR',
- 'runTest (test_runner.test_debug_sql.{}PassingTest) ... ok',
- 'runTest (test_runner.test_debug_sql.{}PassingSubTest) ... ok',
- # If there are errors/failures in subtests but not in test itself,
- # the status is not written. That behavior comes from Python.
- 'runTest (test_runner.test_debug_sql.{}FailingSubTest) ...',
- 'runTest (test_runner.test_debug_sql.{}ErrorSubTest) ...',
- ]
- ] + [
+ 'runTest (test_runner.test_debug_sql.TestDebugSQL.FailingTest) ... FAIL',
+ 'runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorTest) ... ERROR',
+ 'runTest (test_runner.test_debug_sql.TestDebugSQL.PassingTest) ... ok',
+ # If there are errors/failures in subtests but not in test itself,
+ # the status is not written. That behavior comes from Python.
+ 'runTest (test_runner.test_debug_sql.TestDebugSQL.FailingSubTest) ...',
+ 'runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorSubTest) ...',
('''SELECT COUNT(*) AS "__count" '''
'''FROM "test_runner_person" WHERE '''
'''"test_runner_person"."first_name" = 'pass';'''),
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 80ee5a27b5..ff0bda6b8d 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1,5 +1,4 @@
import os
-import sys
import unittest
from io import StringIO
from unittest import mock
@@ -684,9 +683,6 @@ class HTMLEqualTests(SimpleTestCase):
error_msg = (
"First argument is not valid HTML:\n"
"('Unexpected end tag `div` (Line 1, Column 6)', (1, 6))"
- ) if sys.version_info >= (3, 5) else (
- "First argument is not valid HTML:\n"
- "Unexpected end tag `div` (Line 1, Column 6), at line 1, column 7"
)
with self.assertRaisesMessage(AssertionError, error_msg):
self.assertHTMLEqual('< div></ div>', '<div></div>')