diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2021-03-12 08:56:11 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-03-15 13:03:30 +0100 |
| commit | 2cd0ccef04767ebfc3f6619f39f5b7dbee9a783b (patch) | |
| tree | 37d788dbb17c058e406c202aebc2b521c2816b5b /tests/utils_tests/test_regex_helper.py | |
| parent | 7bdd09d016f418719f2d0297f58bd81c5349101d (diff) | |
Added tests for AssertionErrors in get_complete_version() and _lazy_re_compile().
Diffstat (limited to 'tests/utils_tests/test_regex_helper.py')
| -rw-r--r-- | tests/utils_tests/test_regex_helper.py | 11 |
1 files changed, 11 insertions, 0 deletions
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') |
