mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Added tests for AssertionErrors in get_complete_version() and _lazy_re_compile().
This commit is contained in:
parent
7bdd09d016
commit
2cd0ccef04
@ -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')
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django import get_version
|
||||
from django.test import SimpleTestCase
|
||||
from django.utils.version import get_version_tuple
|
||||
from django.utils.version import get_complete_version, get_version_tuple
|
||||
|
||||
|
||||
class VersionTests(SimpleTestCase):
|
||||
@ -28,3 +28,14 @@ class VersionTests(SimpleTestCase):
|
||||
self.assertEqual(get_version_tuple('1.2.3'), (1, 2, 3))
|
||||
self.assertEqual(get_version_tuple('1.2.3b2'), (1, 2, 3))
|
||||
self.assertEqual(get_version_tuple('1.2.3b2.dev0'), (1, 2, 3))
|
||||
|
||||
def test_get_version_invalid_version(self):
|
||||
tests = [
|
||||
# Invalid length.
|
||||
(3, 2, 0, 'alpha', 1, '20210315111111'),
|
||||
# Invalid development status.
|
||||
(3, 2, 0, 'gamma', 1, '20210315111111'),
|
||||
]
|
||||
for version in tests:
|
||||
with self.subTest(version=version), self.assertRaises(AssertionError):
|
||||
get_complete_version(version)
|
||||
|
Loading…
Reference in New Issue
Block a user