summaryrefslogtreecommitdiff
path: root/django/test
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-04-28 18:09:37 +0200
committerClaude Paroz <claude@2xlibre.net>2012-04-29 20:57:15 +0200
commit3904b74a3f2f92fefe1d39281ed683c52f2fef03 (patch)
tree1ae8f65371ed53df205553f41c9d0f90d1e9fee9 /django/test
parenteefb00f30124f775ca52258ccd8549054fe8230f (diff)
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).
Diffstat (limited to 'django/test')
-rw-r--r--django/test/_doctest.py8
-rw-r--r--django/test/client.py2
-rw-r--r--django/test/testcases.py6
3 files changed, 8 insertions, 8 deletions
diff --git a/django/test/_doctest.py b/django/test/_doctest.py
index fe9b2f1890..af2f409e32 100644
--- a/django/test/_doctest.py
+++ b/django/test/_doctest.py
@@ -1626,7 +1626,7 @@ class DebugRunner(DocTestRunner):
... {}, 'foo', 'foo.py', 0)
>>> try:
... runner.run(test)
- ... except UnexpectedException, failure:
+ ... except UnexpectedException as failure:
... pass
>>> failure.test is test
@@ -1654,7 +1654,7 @@ class DebugRunner(DocTestRunner):
>>> try:
... runner.run(test)
- ... except DocTestFailure, failure:
+ ... except DocTestFailure as failure:
... pass
DocTestFailure objects provide access to the test:
@@ -2164,7 +2164,7 @@ class DocTestCase(unittest.TestCase):
>>> case = DocTestCase(test)
>>> try:
... case.debug()
- ... except UnexpectedException, failure:
+ ... except UnexpectedException as failure:
... pass
The UnexpectedException contains the test, the example, and
@@ -2193,7 +2193,7 @@ class DocTestCase(unittest.TestCase):
>>> try:
... case.debug()
- ... except DocTestFailure, failure:
+ ... except DocTestFailure as failure:
... pass
DocTestFailure objects provide access to the test:
diff --git a/django/test/client.py b/django/test/client.py
index 2b26335037..807b4cc55e 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -378,7 +378,7 @@ class Client(RequestFactory):
try:
response = self.handler(environ)
- except TemplateDoesNotExist, e:
+ except TemplateDoesNotExist as e:
# If the view raises an exception, Django will attempt to show
# the 500.html template. If that template is not available,
# we should ignore the error in favor of re-raising the
diff --git a/django/test/testcases.py b/django/test/testcases.py
index b923bde139..c9fe1b3a86 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -84,7 +84,7 @@ def restore_transaction_methods():
def assert_and_parse_html(self, html, user_msg, msg):
try:
dom = parse_html(html)
- except HTMLParseError, e:
+ except HTMLParseError as e:
standardMsg = u'%s\n%s' % (msg, e.msg)
self.fail(self._formatMessage(user_msg, standardMsg))
return dom
@@ -1035,7 +1035,7 @@ class LiveServerThread(threading.Thread):
try:
self.httpd = StoppableWSGIServer(
(self.host, port), QuietWSGIRequestHandler)
- except WSGIServerException, e:
+ except WSGIServerException as e:
if (index + 1 < len(self.possible_ports) and
e.args[0].errno == errno.EADDRINUSE):
# This port is already in use, so we go on and try with
@@ -1054,7 +1054,7 @@ class LiveServerThread(threading.Thread):
self.httpd.set_app(handler)
self.is_ready.set()
self.httpd.serve_forever()
- except Exception, e:
+ except Exception as e:
self.error = e
self.is_ready.set()