MCPcopy
hub / github.com/django/django / _assert_template_used

Method _assert_template_used

django/test/testcases.py:780–797  ·  view source on GitHub ↗
(self, template_name, template_names, msg_prefix, count)

Source from the content-addressed store, hash-verified

778 return None, template_names, msg_prefix
779
780 def _assert_template_used(self, template_name, template_names, msg_prefix, count):
781 if not template_names:
782 self.fail(msg_prefix + "No templates used to render the response")
783 self.assertTrue(
784 template_name in template_names,
785 msg_prefix + "Template '%s' was not a template used to render"
786 " the response. Actual template(s) used: %s"
787 % (template_name, ", ".join(template_names)),
788 )
789
790 if count is not None:
791 self.assertEqual(
792 template_names.count(template_name),
793 count,
794 msg_prefix + "Template '%s' was expected to be rendered %d "
795 "time(s) but was actually rendered %d time(s)."
796 % (template_name, count, template_names.count(template_name)),
797 )
798
799 def assertTemplateUsed(
800 self, response=None, template_name=None, msg_prefix="", count=None

Callers 2

assertTemplateUsedMethod · 0.95
testMethod · 0.80

Calls 2

joinMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected