Added example of assertNumQueries() with "using" kwarg in testing topics docs.

This commit is contained in:
Garry Polley 2019-09-17 20:18:02 -05:00 committed by Mariusz Felisiak
parent d216e67b0c
commit 0b698eaea6
1 changed files with 6 additions and 3 deletions

View File

@ -1675,9 +1675,12 @@ your test suite.
``num`` database queries are executed. ``num`` database queries are executed.
If a ``"using"`` key is present in ``kwargs`` it is used as the database If a ``"using"`` key is present in ``kwargs`` it is used as the database
alias for which to check the number of queries. If you wish to call a alias for which to check the number of queries::
function with a ``using`` parameter you can do it by wrapping the call with
a ``lambda`` to add an extra parameter:: self.assertNumQueries(7, using='non_default_db')
If you wish to call a function with a ``using`` parameter you can do it by
wrapping the call with a ``lambda`` to add an extra parameter::
self.assertNumQueries(7, lambda: my_function(using=7)) self.assertNumQueries(7, lambda: my_function(using=7))