mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Removed unneeded escapes in regexes.
Special characters lose their special meaning inside sets of characters.
"-" lose its special meaning if it's placed as the first or last
character.
Follow up to 7c6b66383d.
This commit is contained in:
@@ -690,24 +690,24 @@ class TestValidatorEquality(TestCase):
|
||||
|
||||
def test_regex_equality(self):
|
||||
self.assertEqual(
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://"),
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://"),
|
||||
)
|
||||
self.assertNotEqual(
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://"),
|
||||
RegexValidator(r"^(?:[0-9\.\-]*)://"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://"),
|
||||
RegexValidator(r"^(?:[0-9.-]*)://"),
|
||||
)
|
||||
self.assertEqual(
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://", "oh noes", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://", "oh noes", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://", "oh noes", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://", "oh noes", "invalid"),
|
||||
)
|
||||
self.assertNotEqual(
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://", "oh", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://", "oh noes", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://", "oh", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://", "oh noes", "invalid"),
|
||||
)
|
||||
self.assertNotEqual(
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://", "oh noes", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9\.\-]*)://"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://", "oh noes", "invalid"),
|
||||
RegexValidator(r"^(?:[a-z0-9.-]*)://"),
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
@@ -721,7 +721,7 @@ class TestValidatorEquality(TestCase):
|
||||
)
|
||||
|
||||
def test_regex_equality_nocache(self):
|
||||
pattern = r"^(?:[a-z0-9\.\-]*)://"
|
||||
pattern = r"^(?:[a-z0-9.-]*)://"
|
||||
left = RegexValidator(pattern)
|
||||
re.purge()
|
||||
right = RegexValidator(pattern)
|
||||
|
||||
Reference in New Issue
Block a user