1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #18013 -- Use the new 'as' syntax for exceptions.

Thanks Clueless for the initial patch.
Note that unittest has been purposely left out (external package only used by Python 2.6).
This commit is contained in:
Claude Paroz
2012-04-28 18:09:37 +02:00
parent eefb00f301
commit 3904b74a3f
107 changed files with 306 additions and 354 deletions

View File

@@ -384,9 +384,9 @@ class ModelTest(TestCase):
try:
Article.objects.all()[0:1] & Article.objects.all()[4:5]
self.fail('Should raise an AssertionError')
except AssertionError, e:
except AssertionError as e:
self.assertEqual(str(e), "Cannot combine queries once a slice has been taken.")
except Exception, e:
except Exception as e:
self.fail('Should raise an AssertionError, not %s' % e)
# Negative slices are not supported, due to database constraints.
@@ -394,15 +394,15 @@ class ModelTest(TestCase):
try:
Article.objects.all()[-1]
self.fail('Should raise an AssertionError')
except AssertionError, e:
except AssertionError as e:
self.assertEqual(str(e), "Negative indexing is not supported.")
except Exception, e:
except Exception as e:
self.fail('Should raise an AssertionError, not %s' % e)
error = None
try:
Article.objects.all()[0:-5]
except Exception, e:
except Exception as e:
error = e
self.assertTrue(isinstance(error, AssertionError))
self.assertEqual(str(error), "Negative indexing is not supported.")