summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-07-12 16:05:14 -0400
committerTim Graham <timograham@gmail.com>2013-07-12 16:06:43 -0400
commit45fab74561a2b339cde922c196ab3ccf998bad10 (patch)
treebfd73d704918d4377ae20f14530865055f00937d /tests/model_fields
parentb30a872973b6903e52d93532175d60d3bf68f888 (diff)
[1.6.x] Fixed #20740 -- GenericIPAddressField should pass protocol to formfield()
Thanks Jeff250. Backport of f2cb94f1c0 from master
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/tests.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index 6abeed8c42..703c0ee8f6 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -468,3 +468,16 @@ class BinaryFieldTests(test.TestCase):
def test_max_length(self):
dm = DataModel(short_data=self.binary_data*4)
self.assertRaises(ValidationError, dm.full_clean)
+
+class GenericIPAddressFieldTests(test.TestCase):
+ def test_genericipaddressfield_formfield_protocol(self):
+ """
+ Test that GenericIPAddressField with a specified protocol does not
+ generate a formfield with no specified protocol. See #20740.
+ """
+ model_field = models.GenericIPAddressField(protocol='IPv4')
+ form_field = model_field.formfield()
+ self.assertRaises(ValidationError, form_field.clean, '::1')
+ model_field = models.GenericIPAddressField(protocol='IPv6')
+ form_field = model_field.formfield()
+ self.assertRaises(ValidationError, form_field.clean, '127.0.0.1')