Ticket #18898: 0001-added-a-failing-test-case-for-18898.patch

File 0001-added-a-failing-test-case-for-18898.patch, 1.5 KB (added by tuxcanfly, 12 years ago)
  • tests/modeltests/model_formsets/tests.py

    From de6c10fe2a7ffae9a0536b912b705b43cbabb0e6 Mon Sep 17 00:00:00 2001
    From: Javed Khan <javed@agiliq.com>
    Date: Sun, 30 Dec 2012 20:39:55 +0530
    Subject: [PATCH] added a failing test case for #18898
    
    ---
     tests/modeltests/model_formsets/tests.py |   16 ++++++++++++++++
     1 file changed, 16 insertions(+)
    
    diff --git a/tests/modeltests/model_formsets/tests.py b/tests/modeltests/model_formsets/tests.py
    index e28560b..01da3e7 100644
    a b class ModelFormsetTest(TestCase):  
    10621062        FormSet = modelformset_factory(ClassyMexicanRestaurant, fields=["tacos_are_yummy"])
    10631063        self.assertEqual(sorted(FormSet().forms[0].fields.keys()), ['restaurant', 'tacos_are_yummy'])
    10641064
     1065    def test_model_formset_with_initial_model_instance(self):
     1066        # has_changed should compare model instance and primary key
     1067        # see #18898
     1068        FormSet = modelformset_factory(Poem)
     1069        john_milton = Poet(name="John Milton")
     1070        john_milton.save()
     1071        data = {
     1072            'form-TOTAL_FORMS': 1,
     1073            'form-INITIAL_FORMS': 0,
     1074            'form-MAX_NUM_FORMS': '',
     1075            'form-0-name': '',
     1076            'form-0-poet': str(john_milton.id),
     1077        }
     1078        formset = FormSet(initial=[{'poet': john_milton}], data=data)
     1079        self.assertFalse(formset.extra_forms[0].has_changed())
     1080
    10651081    def test_prevent_duplicates_from_with_the_same_formset(self):
    10661082        FormSet = modelformset_factory(Product, extra=2)
    10671083        data = {
Back to Top