Ticket #18320: django-ticket18320.diff

File django-ticket18320.diff, 1.1 KB (added by Michael Manfre, 12 years ago)

Check conection features to determine proper num of expected queries.

  • tests/regressiontests/model_formsets_regress/tests.py

    diff --git a/tests/regressiontests/model_formsets_regress/tests.py b/tests/regressiontests/model_formsets_regress/tests.py
    index f1e935e..7d013bd 100644
    a b  
    11from __future__ import absolute_import
    22
    33from django import forms
     4from django.db import connection
    45from django.forms.formsets import BaseFormSet, DELETION_FIELD_NAME
    56from django.forms.util import ErrorDict, ErrorList
    67from django.forms.models import modelform_factory, inlineformset_factory, modelformset_factory, BaseModelFormSet
    class FormsetTests(TestCase):  
    255256                u'test-INITIAL_FORMS': u'0',
    256257                u'test-MAX_NUM_FORMS': u'',
    257258                u'test-0-name': u'Random Place', }
    258         with self.assertNumQueries(1):
     259        expected_num_queries = 1
     260        if not connection.features.can_return_id_from_insert:
     261            expected_num_queries = 2
     262        with self.assertNumQueries(expected_num_queries):
    259263            formset = Formset(data, prefix="test")
    260264            formset.save()
    261265
Back to Top