summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_http.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils_tests/test_http.py')
-rw-r--r--tests/utils_tests/test_http.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
index 05b43c814f..1cbb0d96bf 100644
--- a/tests/utils_tests/test_http.py
+++ b/tests/utils_tests/test_http.py
@@ -5,10 +5,10 @@ from django.test import SimpleTestCase, ignore_warnings
from django.utils.datastructures import MultiValueDict
from django.utils.deprecation import RemovedInDjango30Warning
from django.utils.http import (
- base36_to_int, cookie_date, http_date, int_to_base36, is_safe_url,
- is_same_domain, parse_etags, parse_http_date, quote_etag, urlencode,
- urlquote, urlquote_plus, urlsafe_base64_decode, urlsafe_base64_encode,
- urlunquote, urlunquote_plus,
+ base36_to_int, cookie_date, escape_leading_slashes, http_date,
+ int_to_base36, is_safe_url, is_same_domain, parse_etags, parse_http_date,
+ quote_etag, urlencode, urlquote, urlquote_plus, urlsafe_base64_decode,
+ urlsafe_base64_encode, urlunquote, urlunquote_plus,
)
@@ -275,3 +275,14 @@ class HttpDateProcessingTests(unittest.TestCase):
def test_parsing_asctime(self):
parsed = parse_http_date('Sun Nov 6 08:49:37 1994')
self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37))
+
+
+class EscapeLeadingSlashesTests(unittest.TestCase):
+ def test(self):
+ tests = (
+ ('//example.com', '/%2Fexample.com'),
+ ('//', '/%2F'),
+ )
+ for url, expected in tests:
+ with self.subTest(url=url):
+ self.assertEqual(escape_leading_slashes(url), expected)