Exemple #1
0
 def test_403(self):
     # Ensure no 403.html template exists to test the default case.
     with override_with_test_loader({}):
         response = self.client.get('/raises403/')
         self.assertContains(response,
                             '<h1>403 Forbidden</h1>',
                             status_code=403)
Exemple #2
0
 def test_403_template(self):
     # Set up a test 403.html template.
     with override_with_test_loader({
             '403.html':
             'This is a test template '
             'for a 403 Forbidden error.'
     }):
         response = self.client.get('/raises403/')
         self.assertContains(response, 'test template', status_code=403)
Exemple #3
0
 def test_custom_templates(self):
     """
     Test that 404.html and 500.html templates are picked by their respective
     handler.
     """
     with override_with_test_loader({
             '404.html': 'This is a test template for a 404 error.',
             '500.html': 'This is a test template for a 500 error.'}):
         for code, url in ((404, '/non_existing_url/'), (500, '/server_error/')):
             response = self.client.get(url)
             self.assertContains(response, "test template for a %d error" % code,
                 status_code=code)
Exemple #4
0
 def test_custom_templates(self):
     """
     Test that 404.html and 500.html templates are picked by their respective
     handler.
     """
     with override_with_test_loader({
             '404.html':
             'This is a test template for a 404 error.',
             '500.html':
             'This is a test template for a 500 error.'
     }):
         for code, url in ((404, '/non_existing_url/'), (500,
                                                         '/server_error/')):
             response = self.client.get(url)
             self.assertContains(response,
                                 "test template for a %d error" % code,
                                 status_code=code)
Exemple #5
0
 def test_403_template(self):
     # Set up a test 403.html template.
     with override_with_test_loader({'403.html': 'This is a test template '
                                     'for a 403 Forbidden error.'}):
         response = self.client.get('/raises403/')
         self.assertContains(response, 'test template', status_code=403)
Exemple #6
0
 def test_403(self):
     # Ensure no 403.html template exists to test the default case.
     with override_with_test_loader({}):
         response = self.client.get('/raises403/')
         self.assertContains(response, '<h1>403 Forbidden</h1>', status_code=403)
Exemple #7
0
 def test_403_template(self):
     # Set up a test 403.html template.
     with override_with_test_loader({"403.html": "This is a test template " "for a 403 Forbidden error."}):
         response = self.client.get("/raises403/")
         self.assertContains(response, "test template", status_code=403)