Code

Ticket #16246: 16246.diff

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

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

Line 
1diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
2--- a/tests/modeltests/validation/models.py
3+++ b/tests/modeltests/validation/models.py
4@@ -84,9 +84,9 @@
5     number = models.IntegerField(unique=True, error_messages={'unique': u'Custom unique number message.'})
6 
7 class GenericIPAddressTestModel(models.Model):
8-    generic_ip = models.GenericIPAddressField(blank=True, unique=True)
9-    v4_ip = models.GenericIPAddressField(blank=True, protocol="ipv4")
10-    v6_ip = models.GenericIPAddressField(blank=True, protocol="ipv6")
11+    generic_ip = models.GenericIPAddressField(null=True, blank=True, unique=True)
12+    v4_ip = models.GenericIPAddressField(null=True, blank=True, protocol="ipv4")
13+    v6_ip = models.GenericIPAddressField(null=True, blank=True, protocol="ipv6")
14 
15-class GenericIPAddressWithUnpackUniqueTestModel(models.Model):
16-    generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True)
17+class GenericIPAddrUnpackUniqueModel(models.Model):
18+    generic_v4unpack_ip = models.GenericIPAddressField(null=True, blank=True, unique=True, unpack_ipv4=True)
19diff --git a/tests/modeltests/validation/tests.py b/tests/modeltests/validation/tests.py
20--- a/tests/modeltests/validation/tests.py
21+++ b/tests/modeltests/validation/tests.py
22@@ -3,7 +3,7 @@
23 from django.core.exceptions import NON_FIELD_ERRORS
24 from modeltests.validation import ValidationTestCase
25 from modeltests.validation.models import (Author, Article, ModelToValidate,
26-    GenericIPAddressTestModel, GenericIPAddressWithUnpackUniqueTestModel)
27+    GenericIPAddressTestModel, GenericIPAddrUnpackUniqueModel)
28 
29 # Import other tests for this package.
30 from modeltests.validation.validators import TestModelsWithValidators
31@@ -177,7 +177,7 @@
32         self.assertEqual(None, giptm.full_clean())
33 
34         # These two are the same, because we are doing IPv4 unpacking
35-        giptm = GenericIPAddressWithUnpackUniqueTestModel(generic_v4unpack_ip="::ffff:18.52.18.52")
36+        giptm = GenericIPAddrUnpackUniqueModel(generic_v4unpack_ip="::ffff:18.52.18.52")
37         giptm.save()
38-        giptm = GenericIPAddressWithUnpackUniqueTestModel(generic_v4unpack_ip="18.52.18.52")
39+        giptm = GenericIPAddrUnpackUniqueModel(generic_v4unpack_ip="18.52.18.52")
40         self.assertFailsValidation(giptm.full_clean, ['generic_v4unpack_ip',])
41diff --git a/tests/regressiontests/forms/tests/extra.py b/tests/regressiontests/forms/tests/extra.py
42--- a/tests/regressiontests/forms/tests/extra.py
43+++ b/tests/regressiontests/forms/tests/extra.py
44@@ -495,7 +495,7 @@
45         self.assertFormErrors([u'Enter a valid IPv4 address.'], f.clean, 'fe80::223:6cff:fe8a:2e8a')
46         self.assertFormErrors([u'Enter a valid IPv4 address.'], f.clean, '2a02::223:6cff:fe8a:2e8a')
47 
48-    def test_generic_ipaddress_as_ipv4_only(self):
49+    def test_generic_ipaddress_as_ipv6_only(self):
50         f = GenericIPAddressField(protocol="IPv6")
51         self.assertFormErrors([u'This field is required.'], f.clean, '')
52         self.assertFormErrors([u'This field is required.'], f.clean, None)