Fixed #19204 -- Replaced python2-style exception syntax.
Thanks to garrison for the report and patch.
This commit is contained in:
parent
e8f07f0378
commit
4a71b84266
|
@ -324,7 +324,7 @@ class TestCase(unittest.TestCase):
|
|||
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 @@ class TestCase(unittest.TestCase):
|
|||
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 @@ class TestCase(unittest.TestCase):
|
|||
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 @@ class TestCase(unittest.TestCase):
|
|||
"""
|
||||
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 @@ class TestCase(unittest.TestCase):
|
|||
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)):
|
||||
|
|
|
@ -89,7 +89,7 @@ class TestLoader(unittest.TestLoader):
|
|||
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 @@ class TestLoader(unittest.TestLoader):
|
|||
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)
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class TestProgram(object):
|
|||
else:
|
||||
self.testNames = (self.defaultTest,)
|
||||
self.createTests()
|
||||
except getopt.error, msg:
|
||||
except getopt.error as msg:
|
||||
self.usageExit(msg)
|
||||
|
||||
def createTests(self):
|
||||
|
|
|
@ -138,7 +138,7 @@ class TestSuite(BaseTestSuite):
|
|||
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 @@ class TestSuite(BaseTestSuite):
|
|||
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 @@ class TestSuite(BaseTestSuite):
|
|||
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 @@ class TestSuite(BaseTestSuite):
|
|||
if tearDownClass is not None:
|
||||
try:
|
||||
tearDownClass()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if isinstance(result, _DebugResult):
|
||||
raise
|
||||
className = util.strclass(previousClass)
|
||||
|
|
Loading…
Reference in New Issue