mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user