mirror of
https://github.com/samba-team/samba.git
synced 2025-03-09 08:58:35 +03:00
samba python tests: convert 'except X, e' to 'except X as e'
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
4885937bf8
commit
28134d002b
@ -142,7 +142,7 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase):
|
||||
net.change_password(newpassword=password.encode('utf-8'),
|
||||
oldpassword=USER_PASS,
|
||||
username=USER_NAME)
|
||||
except Exception, msg:
|
||||
except Exception as msg:
|
||||
exception_thrown = True
|
||||
self.assertEquals(True, exception_thrown,
|
||||
"Expected exception not thrown")
|
||||
@ -173,7 +173,7 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase):
|
||||
net.change_password(newpassword=password.encode('utf-8'),
|
||||
oldpassword=USER_PASS,
|
||||
username="badUser")
|
||||
except Exception, msg:
|
||||
except Exception as msg:
|
||||
exception_thrown = True
|
||||
self.assertEquals(True, exception_thrown,
|
||||
"Expected exception not thrown")
|
||||
@ -204,7 +204,7 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase):
|
||||
net.change_password(newpassword=password.encode('utf-8'),
|
||||
oldpassword="badPassword",
|
||||
username=USER_NAME)
|
||||
except Exception, msg:
|
||||
except Exception as msg:
|
||||
exception_thrown = True
|
||||
self.assertEquals(True, exception_thrown,
|
||||
"Expected exception not thrown")
|
||||
|
@ -195,11 +195,11 @@ class ArrayTests(samba.tests.TestCase):
|
||||
try:
|
||||
del rmd1.version
|
||||
self.fail("succeeded in deleting rmd1.version")
|
||||
except AttributeError, e:
|
||||
except AttributeError as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
del rmd.ctr.array
|
||||
self.fail("succeeded in deleting rmd.ctr.array")
|
||||
except AttributeError, e:
|
||||
except AttributeError as e:
|
||||
pass
|
||||
|
@ -45,7 +45,7 @@ class RpcTests(object):
|
||||
continue
|
||||
try:
|
||||
value = getattr(v, n)
|
||||
except TypeError, errstr:
|
||||
except TypeError as errstr:
|
||||
if str(errstr) == "unknown union level":
|
||||
print "ERROR: Unknown union level in %s.%s" % (typename, n)
|
||||
self.errcount += 1
|
||||
@ -68,7 +68,7 @@ class RpcTests(object):
|
||||
try:
|
||||
print "Setting %s.%s" % (typename, n)
|
||||
setattr(v, n, value)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if isinstance(e, AttributeError) and str(e).endswith("is read-only"):
|
||||
# readonly, ignore
|
||||
continue
|
||||
@ -82,7 +82,7 @@ class RpcTests(object):
|
||||
if value != getattr(v, n):
|
||||
print "ERROR: Comparison failed for %s.%s: %r != %r" % (typename, n, value, getattr(v, n))
|
||||
continue
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print "ERROR: compare exception for %s.%s: %r: %s" % (typename, n, e.__class__, e)
|
||||
continue
|
||||
|
||||
@ -104,7 +104,7 @@ class RpcTests(object):
|
||||
initial_blocks = talloc.total_blocks(None)
|
||||
self.check_type(interface, n, value)
|
||||
self.check_blocks(None, initial_blocks)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print "ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e)
|
||||
self.errcount += 1
|
||||
elif callable(value):
|
||||
|
@ -190,7 +190,7 @@ class TestDnsForwarding(DNSTest):
|
||||
s.connect((host, port))
|
||||
try:
|
||||
s.send('timeout 0', 0)
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if e.errno in (errno.ECONNREFUSED, errno.EHOSTUNREACH):
|
||||
continue
|
||||
|
||||
|
@ -42,7 +42,7 @@ def get_documented_parameters(sourcedir):
|
||||
raise Exception("Unable to find parameters.all.xml")
|
||||
try:
|
||||
p = open(os.path.join(path, "parameters.all.xml"), 'r')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
raise Exception("Error opening parameters file")
|
||||
out = p.read()
|
||||
|
||||
@ -65,7 +65,7 @@ def get_documented_tuples(sourcedir, omit_no_default=True):
|
||||
raise Exception("Unable to find parameters.all.xml")
|
||||
try:
|
||||
p = open(os.path.join(path, "parameters.all.xml"), 'r')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
raise Exception("Error opening parameters file")
|
||||
out = p.read()
|
||||
|
||||
|
@ -29,7 +29,7 @@ class NetCmdTestCase(samba.tests.TestCase):
|
||||
cmd = cmd_klass(outf=StringIO(), errf=StringIO())
|
||||
try:
|
||||
retval = cmd._run(cmd_klass.__name__, *args)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
cmd.show_command_error(e)
|
||||
retval = 1
|
||||
self.assertEquals(retcode, retval)
|
||||
|
@ -189,7 +189,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
|
||||
self.assertTrue("testrecord" in out and record_str in out,
|
||||
"Query for a record which had DNS_RANK_NONE" \
|
||||
"succeeded but produced no resulting records.")
|
||||
except AssertionError, e:
|
||||
except AssertionError as e:
|
||||
# Windows produces no resulting records
|
||||
pass
|
||||
|
||||
@ -200,7 +200,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
|
||||
try:
|
||||
self.assertCmdFail(result, "Successfully added duplicate record" \
|
||||
"of one which had DNS_RANK_NONE.")
|
||||
except AssertionError, e:
|
||||
except AssertionError as e:
|
||||
errors.append(e)
|
||||
|
||||
# We should be able to delete it
|
||||
@ -210,7 +210,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
|
||||
try:
|
||||
self.assertCmdSuccess(result, out, err, "Failed to delete record" \
|
||||
"which had DNS_RANK_NONE.")
|
||||
except AssertionError, e:
|
||||
except AssertionError as e:
|
||||
errors.append(e)
|
||||
|
||||
# Now the record should not exist
|
||||
@ -220,7 +220,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
|
||||
try:
|
||||
self.assertCmdFail(result, "Successfully queried for deleted record" \
|
||||
"which had DNS_RANK_NONE.")
|
||||
except AssertionError, e:
|
||||
except AssertionError as e:
|
||||
errors.append(e)
|
||||
|
||||
if len(errors) > 0:
|
||||
|
@ -61,7 +61,7 @@ def get_source_file_contents():
|
||||
for fname in get_python_source_files():
|
||||
try:
|
||||
f = open(fname, 'rb')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
warnings.warn("source file %s broken link?" % fname)
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user