mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Add test to repro duplicate validation error
Using the ModelSerializer with a model containing a GenericIPAddressField produces duplicated validation error messages.
This commit is contained in:
parent
0cbfbc27d8
commit
bc6bf7236b
|
@ -344,6 +344,22 @@ class TestDurationFieldMapping(TestCase):
|
|||
self.assertEqual(unicode_repr(TestSerializer()), expected)
|
||||
|
||||
|
||||
class TestGenericIPAddressFieldValidation(TestCase):
|
||||
def test_ip_address_validation(self):
|
||||
class IPAddressFieldModel(models.Model):
|
||||
address = models.GenericIPAddressField()
|
||||
|
||||
class TestSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = IPAddressFieldModel
|
||||
|
||||
s = TestSerializer(data={'address': 'not an ip address'})
|
||||
self.assertFalse(s.is_valid())
|
||||
self.assertEquals(1, len(s.errors['address']),
|
||||
'Unexpected number of validation errors: '
|
||||
'{0}'.format(s.errors))
|
||||
|
||||
|
||||
# Tests for relational field mappings.
|
||||
# ------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user