Commit 782ff275 authored by Guido van Rossum's avatar Guido van Rossum

Fix errors in bsddb3 tests due to removal of exception slicing.

(There was also a segfault but it disappeared when the tests
stopped erroring out; I presume the segfault is a pre-existing
problem somewhere in a destructor.)
parent cef2098c
...@@ -163,7 +163,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -163,7 +163,7 @@ class BasicTestCase(unittest.TestCase):
try: try:
d.delete('abcd') d.delete('abcd')
except db.DBNotFoundError as val: except db.DBNotFoundError as val:
assert val[0] == db.DB_NOTFOUND assert val.args[0] == db.DB_NOTFOUND
if verbose: print(val) if verbose: print(val)
else: else:
self.fail("expected exception") self.fail("expected exception")
...@@ -182,7 +182,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -182,7 +182,7 @@ class BasicTestCase(unittest.TestCase):
try: try:
d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE) d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
except db.DBKeyExistError as val: except db.DBKeyExistError as val:
assert val[0] == db.DB_KEYEXIST assert val.args[0] == db.DB_KEYEXIST
if verbose: print(val) if verbose: print(val)
else: else:
self.fail("expected exception") self.fail("expected exception")
...@@ -315,7 +315,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -315,7 +315,7 @@ class BasicTestCase(unittest.TestCase):
rec = c.next() rec = c.next()
except db.DBNotFoundError as val: except db.DBNotFoundError as val:
if get_raises_error: if get_raises_error:
assert val[0] == db.DB_NOTFOUND assert val.args[0] == db.DB_NOTFOUND
if verbose: print(val) if verbose: print(val)
rec = None rec = None
else: else:
...@@ -335,7 +335,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -335,7 +335,7 @@ class BasicTestCase(unittest.TestCase):
rec = c.prev() rec = c.prev()
except db.DBNotFoundError as val: except db.DBNotFoundError as val:
if get_raises_error: if get_raises_error:
assert val[0] == db.DB_NOTFOUND assert val.args[0] == db.DB_NOTFOUND
if verbose: print(val) if verbose: print(val)
rec = None rec = None
else: else:
...@@ -358,7 +358,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -358,7 +358,7 @@ class BasicTestCase(unittest.TestCase):
try: try:
n = c.set('bad key') n = c.set('bad key')
except db.DBNotFoundError as val: except db.DBNotFoundError as val:
assert val[0] == db.DB_NOTFOUND assert val.args[0] == db.DB_NOTFOUND
if verbose: print(val) if verbose: print(val)
else: else:
if set_raises_error: if set_raises_error:
...@@ -372,7 +372,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -372,7 +372,7 @@ class BasicTestCase(unittest.TestCase):
try: try:
n = c.get_both('0404', 'bad data') n = c.get_both('0404', 'bad data')
except db.DBNotFoundError as val: except db.DBNotFoundError as val:
assert val[0] == db.DB_NOTFOUND assert val.args[0] == db.DB_NOTFOUND
if verbose: print(val) if verbose: print(val)
else: else:
if get_raises_error: if get_raises_error:
...@@ -401,7 +401,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -401,7 +401,7 @@ class BasicTestCase(unittest.TestCase):
rec = c.current() rec = c.current()
except db.DBKeyEmptyError as val: except db.DBKeyEmptyError as val:
if get_raises_error: if get_raises_error:
assert val[0] == db.DB_KEYEMPTY assert val.args[0] == db.DB_KEYEMPTY
if verbose: print(val) if verbose: print(val)
else: else:
self.fail("unexpected DBKeyEmptyError") self.fail("unexpected DBKeyEmptyError")
...@@ -446,7 +446,7 @@ class BasicTestCase(unittest.TestCase): ...@@ -446,7 +446,7 @@ class BasicTestCase(unittest.TestCase):
# a bug may cause a NULL pointer dereference... # a bug may cause a NULL pointer dereference...
getattr(c, method)(*args) getattr(c, method)(*args)
except db.DBError as val: except db.DBError as val:
assert val[0] == 0 assert val.args[0] == 0
if verbose: print(val) if verbose: print(val)
else: else:
self.fail("no exception raised when using a buggy cursor's" self.fail("no exception raised when using a buggy cursor's"
......
...@@ -64,7 +64,7 @@ class SimpleRecnoTestCase(unittest.TestCase): ...@@ -64,7 +64,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
try: try:
data = d[0] # This should raise a KeyError!?!?! data = d[0] # This should raise a KeyError!?!?!
except db.DBInvalidArgError as val: except db.DBInvalidArgError as val:
assert val[0] == db.EINVAL assert val.args[0] == db.EINVAL
if verbose: print(val) if verbose: print(val)
else: else:
self.fail("expected exception") self.fail("expected exception")
...@@ -181,7 +181,7 @@ class SimpleRecnoTestCase(unittest.TestCase): ...@@ -181,7 +181,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
if get_returns_none: if get_returns_none:
self.fail("unexpected DBKeyEmptyError exception") self.fail("unexpected DBKeyEmptyError exception")
else: else:
assert val[0] == db.DB_KEYEMPTY assert val.args[0] == db.DB_KEYEMPTY
if verbose: print(val) if verbose: print(val)
else: else:
if not get_returns_none: if not get_returns_none:
...@@ -268,7 +268,7 @@ class SimpleRecnoTestCase(unittest.TestCase): ...@@ -268,7 +268,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
try: # this one will fail try: # this one will fail
d.append('bad' * 20) d.append('bad' * 20)
except db.DBInvalidArgError as val: except db.DBInvalidArgError as val:
assert val[0] == db.EINVAL assert val.args[0] == db.EINVAL
if verbose: print(val) if verbose: print(val)
else: else:
self.fail("expected exception") self.fail("expected exception")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment