Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
net.change_password(newpassword=password.encode('utf-8'),
oldpassword=USER_PASS,
username=USER_NAME)
net.change_password(newpassword=password.encode('utf-8'),
oldpassword=USER_PASS,
username=USER_NAME)
+ except Exception as msg:
exception_thrown = True
self.assertEquals(True, exception_thrown,
"Expected exception not thrown")
exception_thrown = True
self.assertEquals(True, exception_thrown,
"Expected exception not thrown")
net.change_password(newpassword=password.encode('utf-8'),
oldpassword=USER_PASS,
username="badUser")
net.change_password(newpassword=password.encode('utf-8'),
oldpassword=USER_PASS,
username="badUser")
+ except Exception as msg:
exception_thrown = True
self.assertEquals(True, exception_thrown,
"Expected exception not thrown")
exception_thrown = True
self.assertEquals(True, exception_thrown,
"Expected exception not thrown")
net.change_password(newpassword=password.encode('utf-8'),
oldpassword="badPassword",
username=USER_NAME)
net.change_password(newpassword=password.encode('utf-8'),
oldpassword="badPassword",
username=USER_NAME)
+ except Exception as msg:
exception_thrown = True
self.assertEquals(True, exception_thrown,
"Expected exception not thrown")
exception_thrown = True
self.assertEquals(True, exception_thrown,
"Expected exception not thrown")
try:
del rmd1.version
self.fail("succeeded in deleting rmd1.version")
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")
pass
try:
del rmd.ctr.array
self.fail("succeeded in deleting rmd.ctr.array")
- except AttributeError, e:
+ except AttributeError as e:
continue
try:
value = getattr(v, n)
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
if str(errstr) == "unknown union level":
print "ERROR: Unknown union level in %s.%s" % (typename, n)
self.errcount += 1
try:
print "Setting %s.%s" % (typename, n)
setattr(v, n, value)
try:
print "Setting %s.%s" % (typename, n)
setattr(v, n, value)
if isinstance(e, AttributeError) and str(e).endswith("is read-only"):
# readonly, ignore
continue
if isinstance(e, AttributeError) and str(e).endswith("is read-only"):
# readonly, ignore
continue
if value != getattr(v, n):
print "ERROR: Comparison failed for %s.%s: %r != %r" % (typename, n, value, getattr(v, n))
continue
if value != getattr(v, n):
print "ERROR: Comparison failed for %s.%s: %r != %r" % (typename, n, value, getattr(v, n))
continue
print "ERROR: compare exception for %s.%s: %r: %s" % (typename, n, e.__class__, e)
continue
print "ERROR: compare exception for %s.%s: %r: %s" % (typename, n, e.__class__, e)
continue
initial_blocks = talloc.total_blocks(None)
self.check_type(interface, n, value)
self.check_blocks(None, initial_blocks)
initial_blocks = talloc.total_blocks(None)
self.check_type(interface, n, value)
self.check_blocks(None, initial_blocks)
print "ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e)
self.errcount += 1
elif callable(value):
print "ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e)
self.errcount += 1
elif callable(value):
s.connect((host, port))
try:
s.send('timeout 0', 0)
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
if e.errno in (errno.ECONNREFUSED, errno.EHOSTUNREACH):
continue
raise Exception("Unable to find parameters.all.xml")
try:
p = open(os.path.join(path, "parameters.all.xml"), 'r')
raise Exception("Unable to find parameters.all.xml")
try:
p = open(os.path.join(path, "parameters.all.xml"), 'r')
raise Exception("Error opening parameters file")
out = p.read()
raise Exception("Error opening parameters file")
out = p.read()
raise Exception("Unable to find parameters.all.xml")
try:
p = open(os.path.join(path, "parameters.all.xml"), 'r')
raise Exception("Unable to find parameters.all.xml")
try:
p = open(os.path.join(path, "parameters.all.xml"), 'r')
raise Exception("Error opening parameters file")
out = p.read()
raise Exception("Error opening parameters file")
out = p.read()
cmd = cmd_klass(outf=StringIO(), errf=StringIO())
try:
retval = cmd._run(cmd_klass.__name__, *args)
cmd = cmd_klass(outf=StringIO(), errf=StringIO())
try:
retval = cmd._run(cmd_klass.__name__, *args)
cmd.show_command_error(e)
retval = 1
self.assertEquals(retcode, retval)
cmd.show_command_error(e)
retval = 1
self.assertEquals(retcode, retval)
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.")
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
# Windows produces no resulting records
pass
try:
self.assertCmdFail(result, "Successfully added duplicate record" \
"of one which had DNS_RANK_NONE.")
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
errors.append(e)
# We should be able to delete it
try:
self.assertCmdSuccess(result, out, err, "Failed to delete record" \
"which had DNS_RANK_NONE.")
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
errors.append(e)
# Now the record should not exist
try:
self.assertCmdFail(result, "Successfully queried for deleted record" \
"which had DNS_RANK_NONE.")
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:
errors.append(e)
if len(errors) > 0:
for fname in get_python_source_files():
try:
f = open(fname, 'rb')
for fname in get_python_source_files():
try:
f = open(fname, 'rb')
if e.errno == errno.ENOENT:
warnings.warn("source file %s broken link?" % fname)
continue
if e.errno == errno.ENOENT:
warnings.warn("source file %s broken link?" % fname)
continue