tests: standardize to modern 'except FooError as err:' syntax

This commit is contained in:
Chris Rebert 2013-05-03 19:53:53 -07:00
parent e4b52f8bf2
commit c487d86fff
6 changed files with 8 additions and 8 deletions

View File

@ -773,7 +773,7 @@ class ShellCase(TestCase):
finally:
try:
process.terminate()
except OSError, err:
except OSError as err:
# process already terminated
pass
@ -785,7 +785,7 @@ class ShellCase(TestCase):
finally:
try:
process.terminate()
except OSError, err:
except OSError as err:
# process already terminated
pass

View File

@ -59,7 +59,7 @@ class PipStateTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
)
try:
os.makedirs(ographite)
except OSError, err:
except OSError as err:
if err.errno == 13:
# Permission denied
self.skipTest(

View File

@ -39,7 +39,7 @@ class SSHKnownHostsStateTest(integration.ModuleCase,
ret = self.run_state('ssh_known_hosts.present', **kwargs)
try:
self.assertSaltTrueReturn(ret)
except AssertionError, err:
except AssertionError as err:
try:
self.assertInSaltComment(
ret, 'Unable to receive remote host key'

View File

@ -95,7 +95,7 @@ def run_integration_tests(opts):
resource.RLIMIT_NOFILE,
(REQUIRED_OPEN_FILES, hmax_open_files)
)
except Exception, err:
except Exception as err:
print('ERROR: Failed to raise the max open files setting -> {0}'.format(err))
print('Please issue the following command on your console:')
print(' ulimit -n {0}'.format(REQUIRED_OPEN_FILES))

View File

@ -36,7 +36,7 @@ class TestLog(TestCase):
# calculations.
try:
saltlog.SaltLoggingClass('{0}.with_digits'.format(__name__))
except Exception, err:
except Exception as err:
raise AssertionError(
'No exception should have been raised: {0}'.format(err)
)
@ -55,7 +55,7 @@ class TestLog(TestCase):
# calculations.
try:
saltlog.SaltLoggingClass('{0}.without_digits'.format(__name__))
except Exception, err:
except Exception as err:
raise AssertionError(
'No exception should have been raised: {0}'.format(err)
)

View File

@ -176,7 +176,7 @@ class TestVerify(TestCase):
handler.messages
)
handler.clear()
except IOError, err:
except IOError as err:
if err.errno == 24:
# Too many open files
self.skipTest('We\'ve hit the max open files setting')