Added tests for AssertionErrors in get_complete_version() and _lazy_re_compile().

This commit is contained in:
Hasan Ramezani 2021-03-12 08:56:11 +01:00 committed by Mariusz Felisiak
parent 7bdd09d016
commit 2cd0ccef04
2 changed files with 23 additions and 1 deletions

View file

@ -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')