diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-24 13:47:01 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-24 13:47:01 +0100 |
| commit | e16c48e001ccd06830bb0bfd1d20e22ec30fce59 (patch) | |
| tree | 3281a2007b0df0ad3653117dbd23a81acda5dea2 /tests/model_fields | |
| parent | ae417dd4d569669e8e1d8f15e643c6ba0820aafe (diff) | |
Fixed #15124 -- Changed the default for BooleanField.
Thanks to the many contributors who updated and improved the patch over
the life of this ticket.
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/tests.py | 14 |
1 files changed, 13 insertions, 1 deletions
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): |
