Ticket #15282: testcase.diff

File testcase.diff, 1.6 KB (added by coleifer, 14 years ago)

testcase indicating failure

  • new file tests/regressiontests/inline_formsets/forms.py

    diff --git a/tests/regressiontests/inline_formsets/forms.py b/tests/regressiontests/inline_formsets/forms.py
    new file mode 100644
    index 0000000..e7d752f
    - +  
     1from django import forms
     2
     3from regressiontests.inline_formsets.models import Poem
     4
     5
     6class PoemModelForm(forms.ModelForm):
     7    class Meta:
     8        model = Poem
  • tests/regressiontests/inline_formsets/tests.py

    diff --git a/tests/regressiontests/inline_formsets/tests.py b/tests/regressiontests/inline_formsets/tests.py
    index 5bd9d18..76d087b 100644
    a b  
    11from django.forms.models import inlineformset_factory
    22from django.test import TestCase
    33
     4from regressiontests.inline_formsets.forms import PoemModelForm
    45from regressiontests.inline_formsets.models import Poet, Poem, School, Parent, Child
    56
    67
    class InlineFormsetFactoryTest(TestCase):  
    154155        inlineformset_factory(
    155156            Parent, Child, exclude=('school',), fk_name='mother'
    156157        )
     158
     159
     160class FormOverrideTestCase(TestCase):
     161    def test_overrides_intact(self):
     162        emily = Poet.objects.create(name='Emily Dickinson')
     163        edgar = Poet.objects.create(name='Edgar Allan Poe')
     164       
     165        # override the queryset
     166        PoemModelForm.base_fields['poet'].queryset = Poet.objects.filter(
     167            name='Emily Dickinson'
     168        )
     169       
     170        # send our form in
     171        formset = inlineformset_factory(
     172            Poet, Poem, form=PoemModelForm, extra=1
     173        )
     174       
     175        self.assertEqual(list(formset.form.base_fields['poet'].queryset), [emily])
Back to Top