"Template assertions work when there is a single context"
"Template assertions work when there is a single context"
response=self.client.get('/post_view/',{})
response=self.client.get('/post_view/',{})
...
@@ -237,6 +243,21 @@ class AssertTemplateUsedTests(TestCase):
...
@@ -237,6 +243,21 @@ class AssertTemplateUsedTests(TestCase):
exceptAssertionErrorase:
exceptAssertionErrorase:
self.assertIn("abc: Template 'Empty POST Template' was not a template used to render the response. Actual template(s) used: Empty GET Template",str(e))
self.assertIn("abc: Template 'Empty POST Template' was not a template used to render the response. Actual template(s) used: Empty GET Template",str(e))
withself.assertRaises(AssertionError)ascontext:
self.assertTemplateUsed(response,'Empty GET Template',count=2)
self.assertIn(
"Template 'Empty GET Template' was expected to be rendered 2 "
"time(s) but was actually rendered 1 time(s).",
str(context.exception))
withself.assertRaises(AssertionError)ascontext:
self.assertTemplateUsed(
response,'Empty GET Template',msg_prefix='abc',count=2)
self.assertIn(
"abc: Template 'Empty GET Template' was expected to be rendered 2 "
"time(s) but was actually rendered 1 time(s).",
str(context.exception))
deftest_multiple_context(self):
deftest_multiple_context(self):
"Template assertions work when there are multiple contexts"
"Template assertions work when there are multiple contexts"
post_data={
post_data={
...
@@ -263,6 +284,19 @@ class AssertTemplateUsedTests(TestCase):
...
@@ -263,6 +284,19 @@ class AssertTemplateUsedTests(TestCase):
exceptAssertionErrorase:
exceptAssertionErrorase:
self.assertIn("Template 'Valid POST Template' was not a template used to render the response. Actual template(s) used: form_view.html, base.html",str(e))
self.assertIn("Template 'Valid POST Template' was not a template used to render the response. Actual template(s) used: form_view.html, base.html",str(e))