1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #23919 -- Simplified assertRaisesRegex()'s that accounted for Python 2.

This commit is contained in:
Tim Graham
2017-01-19 21:10:33 -05:00
committed by Aymeric Augustin
parent dc8834cad4
commit 109b33f64c
12 changed files with 43 additions and 42 deletions

View File

@@ -42,10 +42,10 @@ class RegexFieldTest(SimpleTestCase):
f = RegexField('^[0-9]+$', min_length=5, max_length=10)
with self.assertRaisesMessage(ValidationError, "'Ensure this value has at least 5 characters (it has 3).'"):
f.clean('123')
with self.assertRaisesRegex(
with self.assertRaisesMessage(
ValidationError,
r"'Ensure this value has at least 5 characters \(it has 3\)\.',"
r" u?'Enter a valid value\.'",
"'Ensure this value has at least 5 characters (it has 3).', "
"'Enter a valid value.'",
):
f.clean('abc')
self.assertEqual('12345', f.clean('12345'))