From e16c48e001ccd06830bb0bfd1d20e22ec30fce59 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 24 Mar 2013 13:47:01 +0100 Subject: Fixed #15124 -- Changed the default for BooleanField. Thanks to the many contributors who updated and improved the patch over the life of this ticket. --- tests/model_fields/tests.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/model_fields') diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index eaf84773e3..d3b1e4b868 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -6,7 +6,7 @@ from decimal import Decimal from django import test from django import forms from django.core.exceptions import ValidationError -from django.db import models +from django.db import models, IntegrityError from django.db.models.fields.files import FieldFile from django.utils import six from django.utils import unittest @@ -265,6 +265,18 @@ class BooleanFieldTests(unittest.TestCase): self.assertEqual(mc.bf.bfield, False) self.assertEqual(mc.nbf.nbfield, False) + def test_null_default(self): + """ + Check that a BooleanField defaults to None -- which isn't + a valid value (#15124). + """ + b = BooleanModel() + self.assertIsNone(b.bfield) + with self.assertRaises(IntegrityError): + b.save() + nb = NullBooleanModel() + self.assertIsNone(nb.nbfield) + nb.save() # no error class ChoicesTests(test.TestCase): def test_choices_and_field_display(self): -- cgit v1.3