mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #22369 -- Added count parameter to assertTemplateUsed
This commit is contained in:
parent
09af48c70f
commit
17c1884456
6 changed files with 59 additions and 3 deletions
|
@ -154,7 +154,9 @@ Requests and Responses
|
|||
Tests
|
||||
^^^^^
|
||||
|
||||
* ...
|
||||
* The ``count`` argument was added to
|
||||
:meth:`~django.test.SimpleTestCase.assertTemplateUsed`. This allows you to
|
||||
assert that a template was rendered a specific number of times.
|
||||
|
||||
Validators
|
||||
^^^^^^^^^^
|
||||
|
|
|
@ -1328,13 +1328,19 @@ your test suite.
|
|||
attribute ordering is not significant. See
|
||||
:meth:`~SimpleTestCase.assertHTMLEqual` for more details.
|
||||
|
||||
.. method:: SimpleTestCase.assertTemplateUsed(response, template_name, msg_prefix='')
|
||||
.. method:: SimpleTestCase.assertTemplateUsed(response, template_name, msg_prefix='', count=None)
|
||||
|
||||
Asserts that the template with the given name was used in rendering the
|
||||
response.
|
||||
|
||||
The name is a string such as ``'admin/index.html'``.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
The count argument is an integer indicating the number of times the
|
||||
template should be rendered. Default is ``None``, meaning that the
|
||||
template should be rendered one or more times.
|
||||
|
||||
You can use this as a context manager, like this::
|
||||
|
||||
with self.assertTemplateUsed('index.html'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue