summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/app_loading/tests.py2
-rw-r--r--tests/regressiontests/backends/tests.py6
-rw-r--r--tests/regressiontests/file_uploads/tests.py12
-rw-r--r--tests/regressiontests/forms/tests/error_messages.py2
-rw-r--r--tests/regressiontests/forms/tests/validators.py2
-rw-r--r--tests/regressiontests/middleware/tests.py4
-rw-r--r--tests/regressiontests/middleware_exceptions/tests.py4
-rw-r--r--tests/regressiontests/model_fields/tests.py2
-rw-r--r--tests/regressiontests/model_forms_regress/tests.py2
-rw-r--r--tests/regressiontests/servers/tests.py2
-rw-r--r--tests/regressiontests/settings_tests/tests.py2
-rw-r--r--tests/regressiontests/templates/nodelist.py2
-rw-r--r--tests/regressiontests/templates/tests.py16
-rw-r--r--tests/regressiontests/test_client_regress/models.py100
-rw-r--r--tests/regressiontests/urlpatterns_reverse/tests.py4
15 files changed, 81 insertions, 81 deletions
diff --git a/tests/regressiontests/app_loading/tests.py b/tests/regressiontests/app_loading/tests.py
index 5173338399..0e66a5aad3 100644
--- a/tests/regressiontests/app_loading/tests.py
+++ b/tests/regressiontests/app_loading/tests.py
@@ -61,7 +61,7 @@ class EggLoadingTest(TestCase):
self.assertRaises(ImportError, load_app, 'broken_app')
try:
load_app('broken_app')
- except ImportError, e:
+ except ImportError as e:
# Make sure the message is indicating the actual
# problem in the broken app.
self.assertTrue("modelz" in e.args[0])
diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py
index 3e675cc1ea..038f652698 100644
--- a/tests/regressiontests/backends/tests.py
+++ b/tests/regressiontests/backends/tests.py
@@ -569,7 +569,7 @@ class ThreadTests(TestCase):
connections['default'] = main_thread_connection
try:
models.Person.objects.get(first_name="John", last_name="Doe")
- except DatabaseError, e:
+ except DatabaseError as e:
exceptions.append(e)
t = threading.Thread(target=runner, args=[connections['default']])
t.start()
@@ -607,7 +607,7 @@ class ThreadTests(TestCase):
def runner2(other_thread_connection):
try:
other_thread_connection.close()
- except DatabaseError, e:
+ except DatabaseError as e:
exceptions.add(e)
t2 = threading.Thread(target=runner2, args=[connections['default']])
t2.start()
@@ -624,7 +624,7 @@ class ThreadTests(TestCase):
def runner2(other_thread_connection):
try:
other_thread_connection.close()
- except DatabaseError, e:
+ except DatabaseError as e:
exceptions.add(e)
# Enable thread sharing
connections['default'].allow_thread_sharing = True
diff --git a/tests/regressiontests/file_uploads/tests.py b/tests/regressiontests/file_uploads/tests.py
index b6191ba033..a461ce1702 100644
--- a/tests/regressiontests/file_uploads/tests.py
+++ b/tests/regressiontests/file_uploads/tests.py
@@ -304,7 +304,7 @@ class FileUploadTests(TestCase):
# it raises when there is an attempt to read more than the available bytes:
try:
client.FakePayload('a').read(2)
- except Exception, reference_error:
+ except Exception as reference_error:
pass
# install the custom handler that tries to access request.POST
@@ -312,12 +312,12 @@ class FileUploadTests(TestCase):
try:
response = self.client.post('/file_uploads/upload_errors/', post_data)
- except reference_error.__class__, err:
+ except reference_error.__class__ as err:
self.failIf(
str(err) == str(reference_error),
"Caught a repeated exception that'll cause an infinite loop in file uploads."
)
- except Exception, err:
+ except Exception as err:
# CustomUploadError is the error that should have been raised
self.assertEqual(err.__class__, uploadhandler.CustomUploadError)
@@ -374,9 +374,9 @@ class DirectoryCreationTests(unittest.TestCase):
os.chmod(temp_storage.location, 0500)
try:
self.obj.testfile.save('foo.txt', SimpleUploadedFile('foo.txt', 'x'))
- except OSError, err:
+ except OSError as err:
self.assertEqual(err.errno, errno.EACCES)
- except Exception, err:
+ except Exception:
self.fail("OSError [Errno %s] not raised." % errno.EACCES)
def test_not_a_directory(self):
@@ -386,7 +386,7 @@ class DirectoryCreationTests(unittest.TestCase):
fd.close()
try:
self.obj.testfile.save('foo.txt', SimpleUploadedFile('foo.txt', 'x'))
- except IOError, err:
+ except IOError as err:
# The test needs to be done on a specific string as IOError
# is raised even without the patch (just not early enough)
self.assertEqual(err.args[0],
diff --git a/tests/regressiontests/forms/tests/error_messages.py b/tests/regressiontests/forms/tests/error_messages.py
index 973bf22ab1..7153a3b0a6 100644
--- a/tests/regressiontests/forms/tests/error_messages.py
+++ b/tests/regressiontests/forms/tests/error_messages.py
@@ -13,7 +13,7 @@ class AssertFormErrorsMixin(object):
try:
the_callable(*args, **kwargs)
self.fail("Testing the 'clean' method on %s failed to raise a ValidationError.")
- except ValidationError, e:
+ except ValidationError as e:
self.assertEqual(e.messages, expected)
class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
diff --git a/tests/regressiontests/forms/tests/validators.py b/tests/regressiontests/forms/tests/validators.py
index cadf660ab8..a4cb324815 100644
--- a/tests/regressiontests/forms/tests/validators.py
+++ b/tests/regressiontests/forms/tests/validators.py
@@ -12,5 +12,5 @@ class TestFieldWithValidators(TestCase):
self.assertRaises(ValidationError, field.clean, 'not int nor mail')
try:
field.clean('not int nor mail')
- except ValidationError, e:
+ except ValidationError as e:
self.assertEqual(2, len(e.messages))
diff --git a/tests/regressiontests/middleware/tests.py b/tests/regressiontests/middleware/tests.py
index 3adb10964a..47fca03ba3 100644
--- a/tests/regressiontests/middleware/tests.py
+++ b/tests/regressiontests/middleware/tests.py
@@ -88,7 +88,7 @@ class CommonMiddlewareTest(TestCase):
request)
try:
CommonMiddleware().process_request(request)
- except RuntimeError, e:
+ except RuntimeError as e:
self.assertTrue('end in a slash' in str(e))
settings.DEBUG = False
@@ -202,7 +202,7 @@ class CommonMiddlewareTest(TestCase):
request)
try:
CommonMiddleware().process_request(request)
- except RuntimeError, e:
+ except RuntimeError as e:
self.assertTrue('end in a slash' in str(e))
settings.DEBUG = False
diff --git a/tests/regressiontests/middleware_exceptions/tests.py b/tests/regressiontests/middleware_exceptions/tests.py
index ac5f09a0a8..586aa0f004 100644
--- a/tests/regressiontests/middleware_exceptions/tests.py
+++ b/tests/regressiontests/middleware_exceptions/tests.py
@@ -118,13 +118,13 @@ class BaseMiddlewareExceptionTest(TestCase):
def assert_exceptions_handled(self, url, errors, extra_error=None):
try:
response = self.client.get(url)
- except TestException, e:
+ except TestException:
# Test client intentionally re-raises any exceptions being raised
# during request handling. Hence actual testing that exception was
# properly handled is done by relying on got_request_exception
# signal being sent.
pass
- except Exception, e:
+ except Exception as e:
if type(extra_error) != type(e):
self.fail("Unexpected exception: %s" % e)
self.assertEqual(len(self.exceptions), len(errors))
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index 8fe67fb606..ea1e1c7d99 100644
--- a/tests/regressiontests/model_fields/tests.py
+++ b/tests/regressiontests/model_fields/tests.py
@@ -44,7 +44,7 @@ class BasicFieldTests(test.TestCase):
nullboolean = NullBooleanModel(nbfield=None)
try:
nullboolean.full_clean()
- except ValidationError, e:
+ except ValidationError as e:
self.fail("NullBooleanField failed validation with value of None: %s" % e.messages)
def test_field_repr(self):
diff --git a/tests/regressiontests/model_forms_regress/tests.py b/tests/regressiontests/model_forms_regress/tests.py
index caf24d336c..09da9737a8 100644
--- a/tests/regressiontests/model_forms_regress/tests.py
+++ b/tests/regressiontests/model_forms_regress/tests.py
@@ -333,7 +333,7 @@ class InvalidFieldAndFactory(TestCase):
class Meta:
model = Person
fields = ('name', 'no-field')
- except FieldError, e:
+ except FieldError as e:
# Make sure the exception contains some reference to the
# field responsible for the problem.
self.assertTrue('no-field' in e.args[0])
diff --git a/tests/regressiontests/servers/tests.py b/tests/regressiontests/servers/tests.py
index 3a72550011..c3def15771 100644
--- a/tests/regressiontests/servers/tests.py
+++ b/tests/regressiontests/servers/tests.py
@@ -102,7 +102,7 @@ class LiveServerViews(LiveServerBase):
"""
try:
self.urlopen('/')
- except urllib2.HTTPError, err:
+ except urllib2.HTTPError as err:
self.assertEquals(err.code, 404, 'Expected 404 response')
else:
self.fail('Expected 404 response')
diff --git a/tests/regressiontests/settings_tests/tests.py b/tests/regressiontests/settings_tests/tests.py
index 1dbd5bd849..493ee8021d 100644
--- a/tests/regressiontests/settings_tests/tests.py
+++ b/tests/regressiontests/settings_tests/tests.py
@@ -62,7 +62,7 @@ class ClassDecoratedTestCase(ClassDecoratedTestCaseSuper):
"""
try:
super(ClassDecoratedTestCase, self).test_max_recursion_error()
- except RuntimeError, e:
+ except RuntimeError:
self.fail()
diff --git a/tests/regressiontests/templates/nodelist.py b/tests/regressiontests/templates/nodelist.py
index b78653683f..97aa5af6a7 100644
--- a/tests/regressiontests/templates/nodelist.py
+++ b/tests/regressiontests/templates/nodelist.py
@@ -52,7 +52,7 @@ class ErrorIndexTest(TestCase):
template = get_template_from_string(source)
try:
template.render(context)
- except (RuntimeError, TypeError), e:
+ except (RuntimeError, TypeError) as e:
error_source_index = e.django_template_source[1]
self.assertEqual(error_source_index,
expected_error_source_index)
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 9b6f8d40a4..7de27a08a9 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -41,7 +41,7 @@ from .response import (TemplateResponseTest, CacheMiddlewareTest,
try:
from .loaders import RenderToStringTest, EggLoaderTest
-except ImportError, e:
+except ImportError as e:
if "pkg_resources" in e.message:
pass # If setuptools isn't installed, that's fine. Just move on.
else:
@@ -274,7 +274,7 @@ class Templates(unittest.TestCase):
try:
tmpl = loader.select_template([load_name])
r = tmpl.render(template.Context({}))
- except template.TemplateDoesNotExist, e:
+ except template.TemplateDoesNotExist as e:
settings.TEMPLATE_DEBUG = old_td
self.assertEqual(e.args[0], 'missing.html')
self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r)
@@ -307,7 +307,7 @@ class Templates(unittest.TestCase):
r = None
try:
r = tmpl.render(template.Context({}))
- except template.TemplateDoesNotExist, e:
+ except template.TemplateDoesNotExist as e:
settings.TEMPLATE_DEBUG = old_td
self.assertEqual(e.args[0], 'missing.html')
self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r)
@@ -334,7 +334,7 @@ class Templates(unittest.TestCase):
r = None
try:
r = tmpl.render(template.Context({}))
- except template.TemplateDoesNotExist, e:
+ except template.TemplateDoesNotExist as e:
self.assertEqual(e.args[0], 'missing.html')
self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r)
@@ -343,7 +343,7 @@ class Templates(unittest.TestCase):
tmpl = loader.get_template(load_name)
try:
tmpl.render(template.Context({}))
- except template.TemplateDoesNotExist, e:
+ except template.TemplateDoesNotExist as e:
self.assertEqual(e.args[0], 'missing.html')
self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r)
finally:
@@ -384,7 +384,7 @@ class Templates(unittest.TestCase):
from django.template import Template, TemplateSyntaxError
try:
t = Template("{% if 1 %}lala{% endblock %}{% endif %}")
- except TemplateSyntaxError, e:
+ except TemplateSyntaxError as e:
self.assertEqual(e.args[0], "Invalid block tag: 'endblock', expected 'elif', 'else' or 'endif'")
def test_templates(self):
@@ -1638,7 +1638,7 @@ class TemplateTagLoading(unittest.TestCase):
self.assertRaises(template.TemplateSyntaxError, template.Template, ttext)
try:
template.Template(ttext)
- except template.TemplateSyntaxError, e:
+ except template.TemplateSyntaxError as e:
self.assertTrue('ImportError' in e.args[0])
self.assertTrue('Xtemplate' in e.args[0])
@@ -1650,7 +1650,7 @@ class TemplateTagLoading(unittest.TestCase):
self.assertRaises(template.TemplateSyntaxError, template.Template, ttext)
try:
template.Template(ttext)
- except template.TemplateSyntaxError, e:
+ except template.TemplateSyntaxError as e:
self.assertTrue('ImportError' in e.args[0])
self.assertTrue('Xtemplate' in e.args[0])
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):
diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
index a1c9244918..bb25806830 100644
--- a/tests/regressiontests/urlpatterns_reverse/tests.py
+++ b/tests/regressiontests/urlpatterns_reverse/tests.py
@@ -161,7 +161,7 @@ class URLPatternReverse(TestCase):
for name, expected, args, kwargs in test_data:
try:
got = reverse(name, args=args, kwargs=kwargs)
- except NoReverseMatch, e:
+ except NoReverseMatch:
self.assertEqual(expected, NoReverseMatch)
else:
self.assertEqual(got, expected)
@@ -207,7 +207,7 @@ class ResolverTests(unittest.TestCase):
try:
resolve('/included/non-existent-url', urlconf=urls)
self.fail('resolve did not raise a 404')
- except Resolver404, e:
+ except Resolver404 as e:
# make sure we at least matched the root ('/') url resolver:
self.assertTrue('tried' in e.args[0])
tried = e.args[0]['tried']