summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_regex_helper.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /tests/utils_tests/test_regex_helper.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/utils_tests/test_regex_helper.py')
-rw-r--r--tests/utils_tests/test_regex_helper.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/utils_tests/test_regex_helper.py b/tests/utils_tests/test_regex_helper.py
index 895890bd26..ca918e5be7 100644
--- a/tests/utils_tests/test_regex_helper.py
+++ b/tests/utils_tests/test_regex_helper.py
@@ -8,47 +8,50 @@ from django.utils import regex_helper
class NormalizeTests(unittest.TestCase):
def test_empty(self):
pattern = r""
- expected = [('', [])]
+ expected = [("", [])]
result = regex_helper.normalize(pattern)
self.assertEqual(result, expected)
def test_escape(self):
pattern = r"\\\^\$\.\|\?\*\+\(\)\["
- expected = [('\\^$.|?*+()[', [])]
+ expected = [("\\^$.|?*+()[", [])]
result = regex_helper.normalize(pattern)
self.assertEqual(result, expected)
def test_group_positional(self):
pattern = r"(.*)-(.+)"
- expected = [('%(_0)s-%(_1)s', ['_0', '_1'])]
+ expected = [("%(_0)s-%(_1)s", ["_0", "_1"])]
result = regex_helper.normalize(pattern)
self.assertEqual(result, expected)
def test_group_noncapturing(self):
pattern = r"(?:non-capturing)"
- expected = [('non-capturing', [])]
+ expected = [("non-capturing", [])]
result = regex_helper.normalize(pattern)
self.assertEqual(result, expected)
def test_group_named(self):
pattern = r"(?P<first_group_name>.*)-(?P<second_group_name>.*)"
- expected = [('%(first_group_name)s-%(second_group_name)s',
- ['first_group_name', 'second_group_name'])]
+ expected = [
+ (
+ "%(first_group_name)s-%(second_group_name)s",
+ ["first_group_name", "second_group_name"],
+ )
+ ]
result = regex_helper.normalize(pattern)
self.assertEqual(result, expected)
def test_group_backreference(self):
pattern = r"(?P<first_group_name>.*)-(?P=first_group_name)"
- expected = [('%(first_group_name)s-%(first_group_name)s',
- ['first_group_name'])]
+ expected = [("%(first_group_name)s-%(first_group_name)s", ["first_group_name"])]
result = regex_helper.normalize(pattern)
self.assertEqual(result, expected)
class LazyReCompileTests(SimpleTestCase):
def test_flags_with_pre_compiled_regex(self):
- test_pattern = re.compile('test')
+ test_pattern = re.compile("test")
lazy_test_pattern = regex_helper._lazy_re_compile(test_pattern, re.I)
- msg = 'flags must be empty if regex is passed pre-compiled'
+ msg = "flags must be empty if regex is passed pre-compiled"
with self.assertRaisesMessage(AssertionError, msg):
- lazy_test_pattern.match('TEST')
+ lazy_test_pattern.match("TEST")