mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Used assertRaisesMessage() to test Django's error messages.
This commit is contained in:
@@ -21,8 +21,7 @@ class TestFloatField(TestCase):
|
||||
instance.size = instance
|
||||
msg = (
|
||||
'Tried to update field model_fields.FloatModel.size with a model '
|
||||
'instance, %r. Use a value '
|
||||
'compatible with FloatField.'
|
||||
'instance, %r. Use a value compatible with FloatField.'
|
||||
) % instance
|
||||
with transaction.atomic():
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
@@ -30,5 +29,5 @@ class TestFloatField(TestCase):
|
||||
# Try setting field to object on retrieved object
|
||||
obj = FloatModel.objects.get(pk=instance.id)
|
||||
obj.size = obj
|
||||
with self.assertRaises(TypeError):
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
obj.save()
|
||||
|
||||
Reference in New Issue
Block a user