Ticket #16246: 16246.diff

File 16246.diff, 3.0 KB (added by ramiro, 4 years ago)

Patch that tweaks the described test case problems, renames a clashing test method elsewhere

  • tests/modeltests/validation/models.py

    diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
    a b  
    8484    number = models.IntegerField(unique=True, error_messages={'unique': u'Custom unique number message.'})
    8585
    8686class GenericIPAddressTestModel(models.Model):
    87     generic_ip = models.GenericIPAddressField(blank=True, unique=True)
    88     v4_ip = models.GenericIPAddressField(blank=True, protocol="ipv4")
    89     v6_ip = models.GenericIPAddressField(blank=True, protocol="ipv6")
     87    generic_ip = models.GenericIPAddressField(null=True, blank=True, unique=True)
     88    v4_ip = models.GenericIPAddressField(null=True, blank=True, protocol="ipv4")
     89    v6_ip = models.GenericIPAddressField(null=True, blank=True, protocol="ipv6")
    9090
    91 class GenericIPAddressWithUnpackUniqueTestModel(models.Model):
    92     generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True)
     91class GenericIPAddrUnpackUniqueModel(models.Model):
     92    generic_v4unpack_ip = models.GenericIPAddressField(null=True, blank=True, unique=True, unpack_ipv4=True)
  • tests/modeltests/validation/tests.py

    diff --git a/tests/modeltests/validation/tests.py b/tests/modeltests/validation/tests.py
    a b  
    33from django.core.exceptions import NON_FIELD_ERRORS
    44from modeltests.validation import ValidationTestCase
    55from modeltests.validation.models import (Author, Article, ModelToValidate,
    6     GenericIPAddressTestModel, GenericIPAddressWithUnpackUniqueTestModel)
     6    GenericIPAddressTestModel, GenericIPAddrUnpackUniqueModel)
    77
    88# Import other tests for this package.
    99from modeltests.validation.validators import TestModelsWithValidators
     
    177177        self.assertEqual(None, giptm.full_clean())
    178178
    179179        # These two are the same, because we are doing IPv4 unpacking
    180         giptm = GenericIPAddressWithUnpackUniqueTestModel(generic_v4unpack_ip="::ffff:18.52.18.52")
     180        giptm = GenericIPAddrUnpackUniqueModel(generic_v4unpack_ip="::ffff:18.52.18.52")
    181181        giptm.save()
    182         giptm = GenericIPAddressWithUnpackUniqueTestModel(generic_v4unpack_ip="18.52.18.52")
     182        giptm = GenericIPAddrUnpackUniqueModel(generic_v4unpack_ip="18.52.18.52")
    183183        self.assertFailsValidation(giptm.full_clean, ['generic_v4unpack_ip',])
  • tests/regressiontests/forms/tests/extra.py

    diff --git a/tests/regressiontests/forms/tests/extra.py b/tests/regressiontests/forms/tests/extra.py
    a b  
    495495        self.assertFormErrors([u'Enter a valid IPv4 address.'], f.clean, 'fe80::223:6cff:fe8a:2e8a')
    496496        self.assertFormErrors([u'Enter a valid IPv4 address.'], f.clean, '2a02::223:6cff:fe8a:2e8a')
    497497
    498     def test_generic_ipaddress_as_ipv4_only(self):
     498    def test_generic_ipaddress_as_ipv6_only(self):
    499499        f = GenericIPAddressField(protocol="IPv6")
    500500        self.assertFormErrors([u'This field is required.'], f.clean, '')
    501501        self.assertFormErrors([u'This field is required.'], f.clean, None)
Back to Top