diff options
Diffstat (limited to 'tests/regressiontests/test_client_regress/models.py')
| -rw-r--r-- | tests/regressiontests/test_client_regress/models.py | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py index f75e6458d1..ab4e592239 100644 --- a/tests/regressiontests/test_client_regress/models.py +++ b/tests/regressiontests/test_client_regress/models.py @@ -38,83 +38,83 @@ class AssertContainsTests(TestCase): try: self.assertContains(response, 'text', status_code=999) - except AssertionError, e: + except AssertionError as e: self.assertIn("Couldn't retrieve content: Response code was 200 (expected 999)", str(e)) try: self.assertContains(response, 'text', status_code=999, msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Couldn't retrieve content: Response code was 200 (expected 999)", str(e)) try: self.assertNotContains(response, 'text', status_code=999) - except AssertionError, e: + except AssertionError as e: self.assertIn("Couldn't retrieve content: Response code was 200 (expected 999)", str(e)) try: self.assertNotContains(response, 'text', status_code=999, msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Couldn't retrieve content: Response code was 200 (expected 999)", str(e)) try: self.assertNotContains(response, 'once') - except AssertionError, e: + except AssertionError as e: self.assertIn("Response should not contain 'once'", str(e)) try: self.assertNotContains(response, 'once', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Response should not contain 'once'", str(e)) try: self.assertContains(response, 'never', 1) - except AssertionError, e: + except AssertionError as e: self.assertIn("Found 0 instances of 'never' in response (expected 1)", str(e)) try: self.assertContains(response, 'never', 1, msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Found 0 instances of 'never' in response (expected 1)", str(e)) try: self.assertContains(response, 'once', 0) - except AssertionError, e: + except AssertionError as e: self.assertIn("Found 1 instances of 'once' in response (expected 0)", str(e)) try: self.assertContains(response, 'once', 0, msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Found 1 instances of 'once' in response (expected 0)", str(e)) try: self.assertContains(response, 'once', 2) - except AssertionError, e: + except AssertionError as e: self.assertIn("Found 1 instances of 'once' in response (expected 2)", str(e)) try: self.assertContains(response, 'once', 2, msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Found 1 instances of 'once' in response (expected 2)", str(e)) try: self.assertContains(response, 'twice', 1) - except AssertionError, e: + except AssertionError as e: self.assertIn("Found 2 instances of 'twice' in response (expected 1)", str(e)) try: self.assertContains(response, 'twice', 1, msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Found 2 instances of 'twice' in response (expected 1)", str(e)) try: self.assertContains(response, 'thrice') - except AssertionError, e: + except AssertionError as e: self.assertIn("Couldn't find 'thrice' in response", str(e)) try: self.assertContains(response, 'thrice', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Couldn't find 'thrice' in response", str(e)) try: self.assertContains(response, 'thrice', 3) - except AssertionError, e: + except AssertionError as e: self.assertIn("Found 0 instances of 'thrice' in response (expected 3)", str(e)) try: self.assertContains(response, 'thrice', 3, msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Found 0 instances of 'thrice' in response (expected 3)", str(e)) def test_unicode_contains(self): @@ -175,12 +175,12 @@ class AssertTemplateUsedTests(TestCase): try: self.assertTemplateUsed(response, 'GET Template') - except AssertionError, e: + except AssertionError as e: self.assertIn("No templates used to render the response", str(e)) try: self.assertTemplateUsed(response, 'GET Template', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: No templates used to render the response", str(e)) def test_single_context(self): @@ -189,22 +189,22 @@ class AssertTemplateUsedTests(TestCase): try: self.assertTemplateNotUsed(response, 'Empty GET Template') - except AssertionError, e: + except AssertionError as e: 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') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Template 'Empty GET Template' was used unexpectedly in rendering the response", str(e)) try: self.assertTemplateUsed(response, 'Empty POST Template') - except AssertionError, e: + except AssertionError as e: 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') - except AssertionError, e: + except AssertionError as 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)) def test_multiple_context(self): @@ -220,17 +220,17 @@ class AssertTemplateUsedTests(TestCase): self.assertContains(response, 'POST data OK') try: self.assertTemplateNotUsed(response, "form_view.html") - except AssertionError, e: + except AssertionError as e: self.assertIn("Template 'form_view.html' was used unexpectedly in rendering the response", str(e)) try: self.assertTemplateNotUsed(response, 'base.html') - except AssertionError, e: + except AssertionError as e: self.assertIn("Template 'base.html' was used unexpectedly in rendering the response", str(e)) try: self.assertTemplateUsed(response, "Valid POST Template") - except AssertionError, e: + except AssertionError as 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)) class AssertRedirectsTests(TestCase): @@ -240,12 +240,12 @@ class AssertRedirectsTests(TestCase): response = self.client.get('/test_client/permanent_redirect_view/') try: self.assertRedirects(response, '/test_client/get_view/') - except AssertionError, e: + except AssertionError as e: self.assertIn("Response didn't redirect as expected: Response code was 301 (expected 302)", str(e)) try: self.assertRedirects(response, '/test_client/get_view/', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Response didn't redirect as expected: Response code was 301 (expected 302)", str(e)) def test_lost_query(self): @@ -253,12 +253,12 @@ class AssertRedirectsTests(TestCase): response = self.client.get('/test_client/redirect_view/', {'var': 'value'}) try: self.assertRedirects(response, '/test_client/get_view/') - except AssertionError, e: + except AssertionError as e: self.assertIn("Response redirected to 'http://testserver/test_client/get_view/?var=value', expected 'http://testserver/test_client/get_view/'", str(e)) try: self.assertRedirects(response, '/test_client/get_view/', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Response redirected to 'http://testserver/test_client/get_view/?var=value', expected 'http://testserver/test_client/get_view/'", str(e)) def test_incorrect_target(self): @@ -267,7 +267,7 @@ class AssertRedirectsTests(TestCase): try: # Should redirect to get_view self.assertRedirects(response, '/test_client/some_view/') - except AssertionError, e: + except AssertionError as e: self.assertIn("Response didn't redirect as expected: Response code was 301 (expected 302)", str(e)) def test_target_page(self): @@ -276,13 +276,13 @@ class AssertRedirectsTests(TestCase): try: # The redirect target responds with a 301 code, not 200 self.assertRedirects(response, 'http://testserver/test_client/permanent_redirect_view/') - except AssertionError, e: + except AssertionError as e: self.assertIn("Couldn't retrieve redirection page '/test_client/permanent_redirect_view/': response code was 301 (expected 200)", str(e)) try: # The redirect target responds with a 301 code, not 200 self.assertRedirects(response, 'http://testserver/test_client/permanent_redirect_view/', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Couldn't retrieve redirection page '/test_client/permanent_redirect_view/': response code was 301 (expected 200)", str(e)) def test_redirect_chain(self): @@ -385,12 +385,12 @@ class AssertRedirectsTests(TestCase): response = self.client.get('/test_client/get_view/', follow=True) try: self.assertRedirects(response, '/test_client/get_view/') - except AssertionError, e: + except AssertionError as e: self.assertIn("Response didn't redirect as expected: Response code was 200 (expected 302)", str(e)) try: self.assertRedirects(response, '/test_client/get_view/', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Response didn't redirect as expected: Response code was 200 (expected 302)", str(e)) def test_redirect_on_non_redirect_page(self): @@ -399,12 +399,12 @@ class AssertRedirectsTests(TestCase): response = self.client.get('/test_client/get_view/') try: self.assertRedirects(response, '/test_client/get_view/') - except AssertionError, e: + except AssertionError as e: self.assertIn("Response didn't redirect as expected: Response code was 200 (expected 302)", str(e)) try: self.assertRedirects(response, '/test_client/get_view/', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: Response didn't redirect as expected: Response code was 200 (expected 302)", str(e)) @@ -424,11 +424,11 @@ class AssertFormErrorTests(TestCase): try: self.assertFormError(response, 'wrong_form', 'some_field', 'Some error.') - except AssertionError, e: + except AssertionError as e: self.assertIn("The form 'wrong_form' was not used to render the response", str(e)) try: self.assertFormError(response, 'wrong_form', 'some_field', 'Some error.', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: The form 'wrong_form' was not used to render the response", str(e)) def test_unknown_field(self): @@ -446,11 +446,11 @@ class AssertFormErrorTests(TestCase): try: self.assertFormError(response, 'form', 'some_field', 'Some error.') - except AssertionError, e: + except AssertionError as e: self.assertIn("The form 'form' in context 0 does not contain the field 'some_field'", str(e)) try: self.assertFormError(response, 'form', 'some_field', 'Some error.', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: The form 'form' in context 0 does not contain the field 'some_field'", str(e)) def test_noerror_field(self): @@ -468,11 +468,11 @@ class AssertFormErrorTests(TestCase): try: self.assertFormError(response, 'form', 'value', 'Some error.') - except AssertionError, e: + except AssertionError as e: self.assertIn("The field 'value' on form 'form' in context 0 contains no errors", str(e)) try: self.assertFormError(response, 'form', 'value', 'Some error.', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: The field 'value' on form 'form' in context 0 contains no errors", str(e)) def test_unknown_error(self): @@ -490,11 +490,11 @@ class AssertFormErrorTests(TestCase): try: self.assertFormError(response, 'form', 'email', 'Some error.') - except AssertionError, e: + except AssertionError as e: 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)) try: self.assertFormError(response, 'form', 'email', 'Some error.', msg_prefix='abc') - except AssertionError, e: + except AssertionError as 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)) def test_unknown_nonfield_error(self): @@ -515,11 +515,11 @@ class AssertFormErrorTests(TestCase): try: self.assertFormError(response, 'form', None, 'Some error.') - except AssertionError, e: + except AssertionError as e: self.assertIn("The form 'form' in context 0 does not contain the non-field error 'Some error.' (actual errors: )", str(e)) try: self.assertFormError(response, 'form', None, 'Some error.', msg_prefix='abc') - except AssertionError, e: + except AssertionError as e: self.assertIn("abc: The form 'form' in context 0 does not contain the non-field error 'Some error.' (actual errors: )", str(e)) class LoginTests(TestCase): @@ -676,7 +676,7 @@ class ContextTests(TestCase): try: response.context['does-not-exist'] self.fail('Should not be able to retrieve non-existent key') - except KeyError, e: + except KeyError as e: self.assertEqual(e.args[0], 'does-not-exist') def test_inherited_context(self): @@ -692,7 +692,7 @@ class ContextTests(TestCase): try: response.context['does-not-exist'] self.fail('Should not be able to retrieve non-existent key') - except KeyError, e: + except KeyError as e: self.assertEqual(e.args[0], 'does-not-exist') def test_15368(self): |
