summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-19 08:35:16 +0100
committerCarlton Gibson <carlton@noumenal.es>2021-02-10 10:20:54 +0100
commitec0ff406311de88f4e2a135d784363424fe602aa (patch)
treec1659b85ea145704a1b733d40a6a9a45e9332d0f /tests/utils_tests
parent9c6ba876928fd20194ac3238dc06aeae66d7bd50 (diff)
Fixed #32355 -- Dropped support for Python 3.6 and 3.7
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_autoreload.py8
-rw-r--r--tests/utils_tests/test_http.py67
2 files changed, 5 insertions, 70 deletions
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index 86c510eace..3cb901af7d 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -195,10 +195,10 @@ class TestChildArguments(SimpleTestCase):
with tempfile.TemporaryDirectory() as tmpdir:
exe_path = Path(tmpdir) / 'django-admin.exe'
exe_path.touch()
- with mock.patch('sys.argv', [str(exe_path.with_suffix('')), 'runserver']):
+ with mock.patch('sys.argv', [exe_path.with_suffix(''), 'runserver']):
self.assertEqual(
autoreload.get_child_arguments(),
- [str(exe_path), 'runserver']
+ [exe_path, 'runserver']
)
@mock.patch('sys.warnoptions', [])
@@ -206,10 +206,10 @@ class TestChildArguments(SimpleTestCase):
with tempfile.TemporaryDirectory() as tmpdir:
script_path = Path(tmpdir) / 'django-admin-script.py'
script_path.touch()
- with mock.patch('sys.argv', [str(script_path.with_name('django-admin')), 'runserver']):
+ with mock.patch('sys.argv', [script_path.with_name('django-admin'), 'runserver']):
self.assertEqual(
autoreload.get_child_arguments(),
- [sys.executable, str(script_path), 'runserver']
+ [sys.executable, script_path, 'runserver']
)
@mock.patch('sys.argv', ['does-not-exist', 'runserver'])
diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
index 4c11f91116..675a6e186e 100644
--- a/tests/utils_tests/test_http.py
+++ b/tests/utils_tests/test_http.py
@@ -7,7 +7,7 @@ from django.test import SimpleTestCase
from django.utils.datastructures import MultiValueDict
from django.utils.http import (
base36_to_int, escape_leading_slashes, http_date, int_to_base36,
- is_same_domain, parse_etags, parse_http_date, parse_qsl, quote_etag,
+ is_same_domain, parse_etags, parse_http_date, quote_etag,
url_has_allowed_host_and_scheme, urlencode, urlsafe_base64_decode,
urlsafe_base64_encode,
)
@@ -331,68 +331,3 @@ class EscapeLeadingSlashesTests(unittest.TestCase):
for url, expected in tests:
with self.subTest(url=url):
self.assertEqual(escape_leading_slashes(url), expected)
-
-
-# TODO: Remove when dropping support for PY37. Backport of unit tests for
-# urllib.parse.parse_qsl() from Python 3.8. Copyright (C) 2020 Python Software
-# Foundation (see LICENSE.python).
-class ParseQSLBackportTests(unittest.TestCase):
- def test_parse_qsl(self):
- tests = [
- ('', []),
- ('&', []),
- ('&&', []),
- ('=', [('', '')]),
- ('=a', [('', 'a')]),
- ('a', [('a', '')]),
- ('a=', [('a', '')]),
- ('&a=b', [('a', 'b')]),
- ('a=a+b&b=b+c', [('a', 'a b'), ('b', 'b c')]),
- ('a=1&a=2', [('a', '1'), ('a', '2')]),
- (b'', []),
- (b'&', []),
- (b'&&', []),
- (b'=', [(b'', b'')]),
- (b'=a', [(b'', b'a')]),
- (b'a', [(b'a', b'')]),
- (b'a=', [(b'a', b'')]),
- (b'&a=b', [(b'a', b'b')]),
- (b'a=a+b&b=b+c', [(b'a', b'a b'), (b'b', b'b c')]),
- (b'a=1&a=2', [(b'a', b'1'), (b'a', b'2')]),
- (';', []),
- (';;', []),
- (';a=b', [('a', 'b')]),
- ('a=a+b;b=b+c', [('a', 'a b'), ('b', 'b c')]),
- ('a=1;a=2', [('a', '1'), ('a', '2')]),
- (b';', []),
- (b';;', []),
- (b';a=b', [(b'a', b'b')]),
- (b'a=a+b;b=b+c', [(b'a', b'a b'), (b'b', b'b c')]),
- (b'a=1;a=2', [(b'a', b'1'), (b'a', b'2')]),
- ]
- for original, expected in tests:
- with self.subTest(original):
- result = parse_qsl(original, keep_blank_values=True)
- self.assertEqual(result, expected, 'Error parsing %r' % original)
- expect_without_blanks = [v for v in expected if len(v[1])]
- result = parse_qsl(original, keep_blank_values=False)
- self.assertEqual(result, expect_without_blanks, 'Error parsing %r' % original)
-
- def test_parse_qsl_encoding(self):
- result = parse_qsl('key=\u0141%E9', encoding='latin-1')
- self.assertEqual(result, [('key', '\u0141\xE9')])
- result = parse_qsl('key=\u0141%C3%A9', encoding='utf-8')
- self.assertEqual(result, [('key', '\u0141\xE9')])
- result = parse_qsl('key=\u0141%C3%A9', encoding='ascii')
- self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')])
- result = parse_qsl('key=\u0141%E9-', encoding='ascii')
- self.assertEqual(result, [('key', '\u0141\ufffd-')])
- result = parse_qsl('key=\u0141%E9-', encoding='ascii', errors='ignore')
- self.assertEqual(result, [('key', '\u0141-')])
-
- def test_parse_qsl_max_num_fields(self):
- with self.assertRaises(ValueError):
- parse_qsl('&'.join(['a=a'] * 11), max_num_fields=10)
- with self.assertRaises(ValueError):
- parse_qsl(';'.join(['a=a'] * 11), max_num_fields=10)
- parse_qsl('&'.join(['a=a'] * 10), max_num_fields=10)