Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.5.X] Fixed #19204 -- Replaced python2-style exception syntax.

Thanks to garrison for the report and patch.

Backport of 4a71b84 from master
  • Loading branch information...
commit ef98ae2910a6b5c86e1e0b003110455778e63324 1 parent 1114d82
Florian Apolloner apollo13 authored
16 django/utils/unittest/case.py
View
@@ -324,7 +324,7 @@ def run(self, result=None):
success = False
try:
self.setUp()
- except SkipTest, e:
+ except SkipTest as e:
self._addSkip(result, str(e))
except Exception:
result.addError(self, sys.exc_info())
@@ -333,7 +333,7 @@ def run(self, result=None):
testMethod()
except self.failureException:
result.addFailure(self, sys.exc_info())
- except _ExpectedFailure, e:
+ except _ExpectedFailure as e:
addExpectedFailure = getattr(result, 'addExpectedFailure', None)
if addExpectedFailure is not None:
addExpectedFailure(self, e.exc_info)
@@ -349,7 +349,7 @@ def run(self, result=None):
warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated",
DeprecationWarning)
result.addFailure(self, sys.exc_info())
- except SkipTest, e:
+ except SkipTest as e:
self._addSkip(result, str(e))
except Exception:
result.addError(self, sys.exc_info())
@@ -770,16 +770,16 @@ def assertSetEqual(self, set1, set2, msg=None):
"""
try:
difference1 = set1.difference(set2)
- except TypeError, e:
+ except TypeError as e:
self.fail('invalid type when attempting set difference: %s' % e)
- except AttributeError, e:
+ except AttributeError as e:
self.fail('first argument does not support set difference: %s' % e)
try:
difference2 = set2.difference(set1)
- except TypeError, e:
+ except TypeError as e:
self.fail('invalid type when attempting set difference: %s' % e)
- except AttributeError, e:
+ except AttributeError as e:
self.fail('second argument does not support set difference: %s' % e)
if not (difference1 or difference2):
@@ -980,7 +980,7 @@ def assertRaisesRegexp(self, expected_exception, expected_regexp,
return _AssertRaisesContext(expected_exception, self, expected_regexp)
try:
callable_obj(*args, **kwargs)
- except expected_exception, exc_value:
+ except expected_exception as exc_value:
if isinstance(expected_regexp, basestring):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(str(exc_value)):
4 django/utils/unittest/loader.py
View
@@ -89,7 +89,7 @@ def loadTestsFromModule(self, module, use_load_tests=True):
if use_load_tests and load_tests is not None:
try:
return load_tests(self, tests, None)
- except Exception, e:
+ except Exception as e:
return _make_failed_load_tests(module.__name__, e,
self.suiteClass)
return tests
@@ -295,7 +295,7 @@ def _find_tests(self, start_dir, pattern):
else:
try:
yield load_tests(self, tests, pattern)
- except Exception, e:
+ except Exception as e:
yield _make_failed_load_tests(package.__name__, e,
self.suiteClass)
2  django/utils/unittest/main.py
View
@@ -150,7 +150,7 @@ def parseArgs(self, argv):
else:
self.testNames = (self.defaultTest,)
self.createTests()
- except getopt.error, msg:
+ except getopt.error as msg:
self.usageExit(msg)
def createTests(self):
8 django/utils/unittest/suite.py
View
@@ -138,7 +138,7 @@ def _handleClassSetUp(self, test, result):
if setUpClass is not None:
try:
setUpClass()
- except Exception, e:
+ except Exception as e:
if isinstance(result, _DebugResult):
raise
currentClass._classSetupFailed = True
@@ -172,7 +172,7 @@ def _handleModuleFixture(self, test, result):
if setUpModule is not None:
try:
setUpModule()
- except Exception, e:
+ except Exception as e:
if isinstance(result, _DebugResult):
raise
result._moduleSetUpFailed = True
@@ -203,7 +203,7 @@ def _handleModuleTearDown(self, result):
if tearDownModule is not None:
try:
tearDownModule()
- except Exception, e:
+ except Exception as e:
if isinstance(result, _DebugResult):
raise
errorName = 'tearDownModule (%s)' % previousModule
@@ -225,7 +225,7 @@ def _tearDownPreviousClass(self, test, result):
if tearDownClass is not None:
try:
tearDownClass()
- except Exception, e:
+ except Exception as e:
if isinstance(result, _DebugResult):
raise
className = util.strclass(previousClass)
Please sign in to comment.
Something went wrong with that request. Please try again.