diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2010-10-12 03:33:19 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2010-10-12 03:33:19 +0000 |
| commit | 5506653b777d7547d21ea2d74e9588fb94314b77 (patch) | |
| tree | 34b6e6c3de02848bf793bd3088681ae29c44238d /tests/regressiontests/model_forms_regress/tests.py | |
| parent | ceef628c192127d5e231613bc280d68dc0927fa3 (diff) | |
| download | django-5506653b777d7547d21ea2d74e9588fb94314b77.tar.gz | |
Fixed #5416 -- Added TestCase.assertNumQueries, which tests that a given function executes the correct number of queries.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14183 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/model_forms_regress/tests.py')
| -rw-r--r-- | tests/regressiontests/model_forms_regress/tests.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/tests/regressiontests/model_forms_regress/tests.py b/tests/regressiontests/model_forms_regress/tests.py index 397651a6b8..d695104d50 100644 --- a/tests/regressiontests/model_forms_regress/tests.py +++ b/tests/regressiontests/model_forms_regress/tests.py @@ -1,10 +1,8 @@ import unittest from datetime import date -from django import db from django import forms from django.forms.models import modelform_factory, ModelChoiceField -from django.conf import settings from django.test import TestCase from django.core.exceptions import FieldError, ValidationError from django.core.files.uploadedfile import SimpleUploadedFile @@ -14,14 +12,6 @@ from models import Person, RealPerson, Triple, FilePathModel, Article, \ class ModelMultipleChoiceFieldTests(TestCase): - - def setUp(self): - self.old_debug = settings.DEBUG - settings.DEBUG = True - - def tearDown(self): - settings.DEBUG = self.old_debug - def test_model_multiple_choice_number_of_queries(self): """ Test that ModelMultipleChoiceField does O(1) queries instead of @@ -30,10 +20,8 @@ class ModelMultipleChoiceFieldTests(TestCase): for i in range(30): Person.objects.create(name="Person %s" % i) - db.reset_queries() f = forms.ModelMultipleChoiceField(queryset=Person.objects.all()) - selected = f.clean([1, 3, 5, 7, 9]) - self.assertEquals(len(db.connection.queries), 1) + self.assertNumQueries(1, f.clean, [1, 3, 5, 7, 9]) class TripleForm(forms.ModelForm): class Meta: @@ -312,7 +300,7 @@ class InvalidFieldAndFactory(TestCase): model = Person fields = ('name', 'no-field') except FieldError, e: - # Make sure the exception contains some reference to the + # Make sure the exception contains some reference to the # field responsible for the problem. self.assertTrue('no-field' in e.args[0]) else: |
