Commit bc6bf723 by Ryan Kaneshiro

Add test to repro duplicate validation error

Using the ModelSerializer with a model containing a GenericIPAddressField
produces duplicated validation error messages.
parent 0cbfbc27
...@@ -344,6 +344,22 @@ class TestDurationFieldMapping(TestCase): ...@@ -344,6 +344,22 @@ class TestDurationFieldMapping(TestCase):
self.assertEqual(unicode_repr(TestSerializer()), expected) 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. # Tests for relational field mappings.
# ------------------------------------ # ------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment