#5416: Add assertNumQueries() to testing framework
-----------------------+----------------------------------------------------
Reporter: adrian | Owner: nobody
Status: new | Component: Unit test system
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------+----------------------------------------------------
The Django testing framework should provide {{{assertNumQueries()}}},
which would assert that a given action executed a given number of database
queries. This should work at the view level ("view X uses 3 queries
total") or the individual statement level ("model method X uses only 1
query").
This might have to be implemented as two methods -- a "start counting"
method and a "stop counting" method:
{{{
#!python
def test_something(self):
self.startCountingQueries()
do_something_that_should_only_use_two_queries()
self.assertNumQueries(2)
}}}
In this example, {{{startCountingQueries()}}} would reset the counter to
0, and every query would be tallied from that point on.
{{{assertNumQueries()}}} would simply assert the query count was the given
number.
Note that this depends on #5415, which provides signals for every SQL
query.
--
Ticket URL: <http://code.djangoproject.com/ticket/5416>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---