mirror of
https://github.com/django/django.git
synced 2025-11-01 04:17:59 +00:00
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
This commit is contained in:
parent
6c91521902
commit
69e1e6187a
6 changed files with 35 additions and 60 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue