From 2cd0ccef04767ebfc3f6619f39f5b7dbee9a783b Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 12 Mar 2021 08:56:11 +0100 Subject: Added tests for AssertionErrors in get_complete_version() and _lazy_re_compile(). --- tests/utils_tests/test_regex_helper.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/utils_tests') diff --git a/tests/utils_tests/test_regex_helper.py b/tests/utils_tests/test_regex_helper.py index 77bcd5bb35..895890bd26 100644 --- a/tests/utils_tests/test_regex_helper.py +++ b/tests/utils_tests/test_regex_helper.py @@ -1,5 +1,7 @@ +import re import unittest +from django.test import SimpleTestCase from django.utils import regex_helper @@ -41,3 +43,12 @@ class NormalizeTests(unittest.TestCase): ['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') + lazy_test_pattern = regex_helper._lazy_re_compile(test_pattern, re.I) + msg = 'flags must be empty if regex is passed pre-compiled' + with self.assertRaisesMessage(AssertionError, msg): + lazy_test_pattern.match('TEST') -- cgit v1.3