summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bennett <ubernostrum@gmail.com>2010-03-10 07:42:25 +0000
committerJames Bennett <ubernostrum@gmail.com>2010-03-10 07:42:25 +0000
commitbaa4d3b710d4011b8badcfade907b76d122c33f9 (patch)
treef8ce7b7740b11dbc8308c614daf1b0157c919a33
parentcccd106289c409c0aa82bf9e37912abbc195d3f1 (diff)
Tests for [12744], which were accidentally left out of the commit. Refs #13071.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12745 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/regressiontests/model_fields/models.py6
-rw-r--r--tests/regressiontests/model_fields/tests.py14
2 files changed, 18 insertions, 2 deletions
diff --git a/tests/regressiontests/model_fields/models.py b/tests/regressiontests/model_fields/models.py
index 39c9abe17d..0e365fec30 100644
--- a/tests/regressiontests/model_fields/models.py
+++ b/tests/regressiontests/model_fields/models.py
@@ -63,7 +63,11 @@ class BigInt(models.Model):
class Post(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()
-
+
+class NullBooleanModel(models.Model):
+ nbfield = models.NullBooleanField()
+
+
###############################################################################
# ImageField
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index d7591d5a22..9d50daf871 100644
--- a/tests/regressiontests/model_fields/tests.py
+++ b/tests/regressiontests/model_fields/tests.py
@@ -6,7 +6,7 @@ from django import forms
from django.db import models
from django.core.exceptions import ValidationError
-from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post
+from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel
try:
from decimal import Decimal
@@ -40,6 +40,18 @@ class BasicFieldTests(django.test.TestCase):
form_field = model_field.formfield(show_hidden_initial=False)
self.assertFalse(form_field.show_hidden_initial)
+ def test_nullbooleanfield_blank(self):
+ """
+ Regression test for #13071: NullBooleanField should not throw
+ a validation error when given a value of None.
+
+ """
+ nullboolean = NullBooleanModel(nbfield=None)
+ try:
+ nullboolean.full_clean()
+ except ValidationError, e:
+ self.fail("NullBooleanField failed validation with value of None: %s" % e.messages)
+
class DecimalFieldTests(django.test.TestCase):
def test_to_python(self):
f = models.DecimalField(max_digits=4, decimal_places=2)