diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2011-10-14 17:03:08 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2011-10-14 17:03:08 +0000 |
| commit | 69e1e6187a1263cdabbc0c177a1e08b1a8107a2c (patch) | |
| tree | 22fb0926f57af72a137e8906daa7426434e75df3 /tests/regressiontests/forms | |
| parent | 6c915219027ca5785db30767620680380ff9377d (diff) | |
Switch several assertNumQueries to use the context manager, which is much more beautiful.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16986 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms')
| -rw-r--r-- | tests/regressiontests/forms/tests/models.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tests/regressiontests/forms/tests/models.py b/tests/regressiontests/forms/tests/models.py index 89b33097ea..12546081d7 100644 --- a/tests/regressiontests/forms/tests/models.py +++ b/tests/regressiontests/forms/tests/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import +from __future__ import with_statement, absolute_import import datetime @@ -28,11 +28,10 @@ class TestTicket12510(TestCase): self.groups = [Group.objects.create(name=name) for name in 'abc'] def test_choices_not_fetched_when_not_rendering(self): - def test(): + # only one query is required to pull the model from DB + with self.assertNumQueries(1): field = ModelChoiceField(Group.objects.order_by('-name')) self.assertEqual('a', field.clean(self.groups[0].pk).name) - # only one query is required to pull the model from DB - self.assertNumQueries(1, test) class ModelFormCallableModelDefault(TestCase): def test_no_empty_option(self): |
