Ticket #15124: t15124_r1.2.4_v1.diff

File t15124_r1.2.4_v1.diff, 2.1 KB (added by Andrew Badr, 14 years ago)

Fix + test + fix for unrelated test

  • django/db/models/fields/__init__.py

    diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
    index fd0a295..7e07c52 100644
    a b class BooleanField(Field):  
    495495    description = _("Boolean (Either True or False)")
    496496    def __init__(self, *args, **kwargs):
    497497        kwargs['blank'] = True
    498         if 'default' not in kwargs and not kwargs.get('null'):
    499             kwargs['default'] = False
    500498        Field.__init__(self, *args, **kwargs)
    501499
    502500    def get_internal_type(self):
  • tests/regressiontests/model_fields/tests.py

    diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
    index 72a7d4d..fae3bfd 100644
    a b class BooleanFieldTests(unittest.TestCase):  
    193193            select={'string_length': 'LENGTH(string)'})[0]
    194194        self.assertFalse(isinstance(b5.pk, bool))
    195195
     196    def test_null_default(self):
     197        # http://code.djangoproject.com/ticket/15124
     198        from django.db import IntegrityError
     199        b = BooleanModel()
     200        self.assertEqual(b.bfield, None)
     201        self.assertRaises(IntegrityError, b.save)
     202
    196203class ChoicesTests(django.test.TestCase):
    197204    def test_choices_and_field_display(self):
    198205        """
  • tests/regressiontests/model_inheritance_regress/tests.py

    diff --git a/tests/regressiontests/model_inheritance_regress/tests.py b/tests/regressiontests/model_inheritance_regress/tests.py
    index dac2cb5..5f976ad 100644
    a b class ModelInheritanceTest(TestCase):  
    178178        """
    179179        Regression test for #6755
    180180        """
    181         r = Restaurant(serves_pizza=False)
     181        r = Restaurant(serves_pizza=False, serves_hot_dogs=False)
    182182        r.save()
    183183        self.assertEqual(r.id, r.place_ptr_id)
    184184        orig_id = r.id
    185         r = Restaurant(place_ptr_id=orig_id, serves_pizza=True)
     185        r = Restaurant(place_ptr_id=orig_id, serves_pizza=True, serves_hot_dogs=False)
    186186        r.save()
    187187        self.assertEqual(r.id, orig_id)
    188188        self.assertEqual(r.id, r.place_ptr_id)
Back to Top