diff options
Diffstat (limited to 'django/test')
| -rw-r--r-- | django/test/client.py | 6 | ||||
| -rw-r--r-- | django/test/html.py | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/django/test/client.py b/django/test/client.py index 98ede36499..0a683f5026 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -1,7 +1,6 @@ import json import mimetypes import os -import re import sys from copy import copy from functools import partial @@ -26,15 +25,16 @@ from django.utils.encoding import force_bytes from django.utils.functional import SimpleLazyObject from django.utils.http import urlencode from django.utils.itercompat import is_iterable +from django.utils.regex_helper import _lazy_re_compile __all__ = ('Client', 'RedirectCycleError', 'RequestFactory', 'encode_file', 'encode_multipart') BOUNDARY = 'BoUnDaRyStRiNg' MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY -CONTENT_TYPE_RE = re.compile(r'.*; charset=([\w\d-]+);?') +CONTENT_TYPE_RE = _lazy_re_compile(r'.*; charset=([\w\d-]+);?') # Structured suffix spec: https://tools.ietf.org/html/rfc6838#section-4.2.8 -JSON_CONTENT_TYPE_RE = re.compile(r'^application\/(.+\+)?json') +JSON_CONTENT_TYPE_RE = _lazy_re_compile(r'^application\/(.+\+)?json') class RedirectCycleError(Exception): diff --git a/django/test/html.py b/django/test/html.py index 511c08bb26..36b44b0466 100644 --- a/django/test/html.py +++ b/django/test/html.py @@ -1,12 +1,13 @@ """Compare two HTML documents.""" -import re from html.parser import HTMLParser +from django.utils.regex_helper import _lazy_re_compile + # ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 # SPACE. # https://infra.spec.whatwg.org/#ascii-whitespace -ASCII_WHITESPACE = re.compile(r'[\t\n\f\r ]+') +ASCII_WHITESPACE = _lazy_re_compile(r'[\t\n\f\r ]+') def normalize_whitespace(string): |
