@@ -278,24 +278,23 @@ Example
278
278
assert settings.USE_TZ
279
279
280
280
281
+ .. fixture :: django_assert_num_queries
282
+
281
283
``django_assert_num_queries ``
282
284
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283
285
284
- .. fixture :: django_assert_num_queries
286
+ .. py :function :: django_assert_num_queries(connection = None , info = None )
287
+
288
+ :param connection: optional non-default DB connection
289
+ :param str info: optional info message to display on failure
285
290
286
291
This fixture allows to check for an expected number of DB queries.
287
292
288
- It wraps `django.test.utils.CaptureQueriesContext `. A non-default DB
289
- connection can be passed in using the `connection ` keyword argument, an
290
- additional info message which is displayed on fail can be passed in using
291
- the `info ` keyword argument, and it will yield the wrapped
293
+ It wraps `django.test.utils.CaptureQueriesContext ` and yields the wrapped
292
294
CaptureQueriesContext instance.
293
295
294
296
295
- Example
296
- """""""
297
-
298
- ::
297
+ Example usage::
299
298
300
299
def test_queries(django_assert_num_queries):
301
300
with django_assert_num_queries(3) as captured:
@@ -306,20 +305,21 @@ Example
306
305
assert 'foo' in captured.captured_queries[0]['sql']
307
306
308
307
308
+ .. fixture :: django_assert_max_num_queries
309
+
309
310
``django_assert_max_num_queries ``
310
311
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311
312
312
- .. fixture :: django_assert_max_num_queries
313
+ .. py :function :: django_assert_num_queries(connection = None , info = None )
314
+
315
+ :param connection: optional non-default DB connection
316
+ :param str info: optional info message to display on failure
313
317
314
318
This fixture allows to check for an expected maximum number of DB queries.
315
319
316
320
It is a specialized version of :fixture: `django_assert_num_queries `.
317
321
318
-
319
- Example
320
- """""""
321
-
322
- ::
322
+ Example usage::
323
323
324
324
def test_max_queries(django_assert_max_num_queries):
325
325
with django_assert_max_num_queries(3):
0 commit comments