self.assertTemplateNotUsed(response,'Empty GET Template')
exceptAssertionErrorase:
self.assertIn("Template 'Empty GET Template' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateNotUsed(response,'Empty GET Template',msg_prefix='abc')
exceptAssertionErrorase:
self.assertIn("abc: Template 'Empty GET Template' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateUsed(response,'Empty POST Template')
exceptAssertionErrorase:
self.assertIn("Template 'Empty POST Template' was not a template used to render the response. Actual template(s) used: Empty GET Template",str(e))
try:
self.assertTemplateUsed(response,'Empty POST Template',msg_prefix='abc')
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))
deftest_multiple_context(self):
"Template assertions work when there are multiple contexts"
self.assertIn("Template 'form_view.html' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateNotUsed(response,'base.html')
exceptAssertionErrorase:
self.assertIn("Template 'base.html' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateUsed(response,"Valid POST Template")
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))
classAssertRedirectsTests(TestCase):
deftest_redirect_page(self):
"An assertion is raised if the original page couldn't be retrieved as expected"
self.assertIn("The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [u'Enter a valid e-mail address.'])",str(e))
self.assertIn("abc: The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [u'Enter a valid e-mail address.'])",str(e))
deftest_unknown_nonfield_error(self):
"""
Checks that an assertion is raised if the form's non field errors
self.assertTemplateNotUsed(response,'Empty GET Template')
exceptAssertionErrorase:
self.assertIn("Template 'Empty GET Template' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateNotUsed(response,'Empty GET Template',msg_prefix='abc')
exceptAssertionErrorase:
self.assertIn("abc: Template 'Empty GET Template' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateUsed(response,'Empty POST Template')
exceptAssertionErrorase:
self.assertIn("Template 'Empty POST Template' was not a template used to render the response. Actual template(s) used: Empty GET Template",str(e))
try:
self.assertTemplateUsed(response,'Empty POST Template',msg_prefix='abc')
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))
deftest_multiple_context(self):
"Template assertions work when there are multiple contexts"
self.assertIn("Template 'form_view.html' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateNotUsed(response,'base.html')
exceptAssertionErrorase:
self.assertIn("Template 'base.html' was used unexpectedly in rendering the response",str(e))
try:
self.assertTemplateUsed(response,"Valid POST Template")
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))
classAssertRedirectsTests(TestCase):
deftest_redirect_page(self):
"An assertion is raised if the original page couldn't be retrieved as expected"
self.assertIn("The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [u'Enter a valid e-mail address.'])",str(e))
self.assertIn("abc: The field 'email' on form 'form' in context 0 does not contain the error 'Some error.' (actual errors: [u'Enter a valid e-mail address.'])",str(e))
deftest_unknown_nonfield_error(self):
"""
Checks that an assertion is raised if the form's non field errors