summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Phillips <jphillips@imap.cc>2016-04-29 11:44:56 +0100
committerTim Graham <timograham@gmail.com>2016-04-29 10:11:49 -0400
commit4681d65048ca2553895e10c2c492997b0a78ffba (patch)
treecc533591f58a7c2db3dba2337dd6f79223bffa97 /tests
parent2f698cd9916cb3d64932248c7114049e02b74fb3 (diff)
Fixed #26557 -- Converted empty strings to None when saving GenericIPAddressField.
Diffstat (limited to 'tests')
-rw-r--r--tests/model_fields/test_genericipaddressfield.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/model_fields/test_genericipaddressfield.py b/tests/model_fields/test_genericipaddressfield.py
index 7a3705ef18..c65fe805cb 100644
--- a/tests/model_fields/test_genericipaddressfield.py
+++ b/tests/model_fields/test_genericipaddressfield.py
@@ -29,6 +29,14 @@ class GenericIPAddressFieldTests(TestCase):
o = GenericIPAddress.objects.get()
self.assertIsNone(o.ip)
+ def test_blank_string_saved_as_null(self):
+ o = GenericIPAddress.objects.create(ip='')
+ o.refresh_from_db()
+ self.assertIsNone(o.ip)
+ GenericIPAddress.objects.update(ip='')
+ o.refresh_from_db()
+ self.assertIsNone(o.ip)
+
def test_save_load(self):
instance = GenericIPAddress.objects.create(ip='::1')
loaded = GenericIPAddress.objects.get()