

def test_null_default(self):
    "\n        A BooleanField defaults to None, which isn't a valid value (#15124).\n        "
    boolean_field = BooleanModel._meta.get_field('bfield')
    self.assertFalse(boolean_field.has_default())
    b = BooleanModel()
    self.assertIsNone(b.bfield)
    with transaction.atomic():
        with self.assertRaises(IntegrityError):
            b.save()
    nb = NullBooleanModel()
    self.assertIsNone(nb.nbfield)
    nb.save()

dataset/ETHPy150Open django/django/tests/model_fields/test_booleanfield.py BooleanFieldTests.test_null_default/original