Ticket #10928: 10928-r11178.diff

File 10928-r11178.diff, 2.0 KB (added by SafPlusPlus <freark@…>, 15 years ago)

Regression test for #10928

  • tests/regressiontests/model_forms_regress/tests.py

     
    66from django.conf import settings
    77from django.test import TestCase
    88
    9 from models import Person, Triple, FilePathModel, Article, Publication, CustomFF
     9from models import Person, Triple, FilePathModel, Article, Publication, CustomFF, DirectDefaultBoolean, CallableDefaultBoolean
    1010
    1111class ModelMultipleChoiceFieldTests(TestCase):
    1212
     
    100100        # It's enough that the form saves without error -- the custom save routine will
    101101        # generate an AssertionError if it is called more than once during save.
    102102        form = CFFForm(data = {'f': None})
    103         form.save()
    104  No newline at end of file
     103        form.save()
     104       
     105class DirectDefaultBooleanForm(forms.ModelForm):
     106    class Meta:
     107        model = DirectDefaultBoolean
     108
     109class CallableDefaultBooleanForm(forms.ModelForm):
     110    class Meta:
     111        model = CallableDefaultBoolean
     112       
     113class CallableVersusDirectDefaultTests(TestCase):
     114    def test_equality(self):
     115        "Regression for #10928: BooleanField: different behaviour when default=callable"
     116       
     117        self.assertEquals(DirectDefaultBooleanForm().as_p(), CallableDefaultBooleanForm().as_p())
     118       
     119 No newline at end of file
  • tests/regressiontests/model_forms_regress/models.py

     
    3737
    3838class CustomFF(models.Model):
    3939    f = CustomFileField(upload_to='unused', blank=True)
     40   
     41class DirectDefaultBoolean(models.Model):
     42    b = models.BooleanField(default=False)
     43
     44class CallableDefaultBoolean(models.Model):
     45    b = models.BooleanField(default=lambda: False)
     46
     47
Back to Top