Skip to content

Commit bc6bf72

Browse files
committed
Add test to repro duplicate validation error
Using the ModelSerializer with a model containing a GenericIPAddressField produces duplicated validation error messages.
1 parent 0cbfbc2 commit bc6bf72

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_model_serializer.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,22 @@ class Meta:
344344
self.assertEqual(unicode_repr(TestSerializer()), expected)
345345

346346

347+
class TestGenericIPAddressFieldValidation(TestCase):
348+
def test_ip_address_validation(self):
349+
class IPAddressFieldModel(models.Model):
350+
address = models.GenericIPAddressField()
351+
352+
class TestSerializer(serializers.ModelSerializer):
353+
class Meta:
354+
model = IPAddressFieldModel
355+
356+
s = TestSerializer(data={'address': 'not an ip address'})
357+
self.assertFalse(s.is_valid())
358+
self.assertEquals(1, len(s.errors['address']),
359+
'Unexpected number of validation errors: '
360+
'{0}'.format(s.errors))
361+
362+
347363
# Tests for relational field mappings.
348364
# ------------------------------------
349365

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy