mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #27579 -- Added aliases for Python 3's assertion names in SimpleTestCase.
This commit is contained in:
@@ -5,7 +5,6 @@ import re
|
||||
|
||||
from django.forms import RegexField, ValidationError
|
||||
from django.test import SimpleTestCase
|
||||
from django.utils import six
|
||||
|
||||
|
||||
class RegexFieldTest(SimpleTestCase):
|
||||
@@ -46,12 +45,12 @@ 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')
|
||||
six.assertRaisesRegex(
|
||||
self, ValidationError,
|
||||
with self.assertRaisesRegex(
|
||||
ValidationError,
|
||||
r"'Ensure this value has at least 5 characters \(it has 3\)\.',"
|
||||
r" u?'Enter a valid value\.'",
|
||||
f.clean, 'abc'
|
||||
)
|
||||
):
|
||||
f.clean('abc')
|
||||
self.assertEqual('12345', f.clean('12345'))
|
||||
self.assertEqual('1234567890', f.clean('1234567890'))
|
||||
with self.assertRaisesMessage(ValidationError, "'Ensure this value has at most 10 characters (it has 11).'"):
|
||||
|
||||
Reference in New Issue
Block a user