[Python-3000-checkins] r54600 - python/branches/p3yk/Lib/bsddb/test/test_basics.py python/branches/p3yk/Lib/bsddb/test/test_recno.py

guido.van.rossum python-3000-checkins at python.org
Wed Mar 28 23:02:46 CEST 2007


Author: guido.van.rossum
Date: Wed Mar 28 23:02:43 2007
New Revision: 54600

Modified:
   python/branches/p3yk/Lib/bsddb/test/test_basics.py
   python/branches/p3yk/Lib/bsddb/test/test_recno.py
Log:
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.)


Modified: python/branches/p3yk/Lib/bsddb/test/test_basics.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_basics.py	(original)
+++ python/branches/p3yk/Lib/bsddb/test/test_basics.py	Wed Mar 28 23:02:43 2007
@@ -163,7 +163,7 @@
         try:
             d.delete('abcd')
         except db.DBNotFoundError as val:
-            assert val[0] == db.DB_NOTFOUND
+            assert val.args[0] == db.DB_NOTFOUND
             if verbose: print(val)
         else:
             self.fail("expected exception")
@@ -182,7 +182,7 @@
         try:
             d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
         except db.DBKeyExistError as val:
-            assert val[0] == db.DB_KEYEXIST
+            assert val.args[0] == db.DB_KEYEXIST
             if verbose: print(val)
         else:
             self.fail("expected exception")
@@ -315,7 +315,7 @@
                 rec = c.next()
             except db.DBNotFoundError as val:
                 if get_raises_error:
-                    assert val[0] == db.DB_NOTFOUND
+                    assert val.args[0] == db.DB_NOTFOUND
                     if verbose: print(val)
                     rec = None
                 else:
@@ -335,7 +335,7 @@
                 rec = c.prev()
             except db.DBNotFoundError as val:
                 if get_raises_error:
-                    assert val[0] == db.DB_NOTFOUND
+                    assert val.args[0] == db.DB_NOTFOUND
                     if verbose: print(val)
                     rec = None
                 else:
@@ -358,7 +358,7 @@
         try:
             n = c.set('bad key')
         except db.DBNotFoundError as val:
-            assert val[0] == db.DB_NOTFOUND
+            assert val.args[0] == db.DB_NOTFOUND
             if verbose: print(val)
         else:
             if set_raises_error:
@@ -372,7 +372,7 @@
         try:
             n = c.get_both('0404', 'bad data')
         except db.DBNotFoundError as val:
-            assert val[0] == db.DB_NOTFOUND
+            assert val.args[0] == db.DB_NOTFOUND
             if verbose: print(val)
         else:
             if get_raises_error:
@@ -401,7 +401,7 @@
             rec = c.current()
         except db.DBKeyEmptyError as val:
             if get_raises_error:
-                assert val[0] == db.DB_KEYEMPTY
+                assert val.args[0] == db.DB_KEYEMPTY
                 if verbose: print(val)
             else:
                 self.fail("unexpected DBKeyEmptyError")
@@ -446,7 +446,7 @@
                 # a bug may cause a NULL pointer dereference...
                 getattr(c, method)(*args)
             except db.DBError as val:
-                assert val[0] == 0
+                assert val.args[0] == 0
                 if verbose: print(val)
             else:
                 self.fail("no exception raised when using a buggy cursor's"

Modified: python/branches/p3yk/Lib/bsddb/test/test_recno.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_recno.py	(original)
+++ python/branches/p3yk/Lib/bsddb/test/test_recno.py	Wed Mar 28 23:02:43 2007
@@ -64,7 +64,7 @@
         try:
             data = d[0]  # This should raise a KeyError!?!?!
         except db.DBInvalidArgError as val:
-            assert val[0] == db.EINVAL
+            assert val.args[0] == db.EINVAL
             if verbose: print(val)
         else:
             self.fail("expected exception")
@@ -181,7 +181,7 @@
             if get_returns_none:
                 self.fail("unexpected DBKeyEmptyError exception")
             else:
-                assert val[0] == db.DB_KEYEMPTY
+                assert val.args[0] == db.DB_KEYEMPTY
                 if verbose: print(val)
         else:
             if not get_returns_none:
@@ -268,7 +268,7 @@
         try:                    # this one will fail
             d.append('bad' * 20)
         except db.DBInvalidArgError as val:
-            assert val[0] == db.EINVAL
+            assert val.args[0] == db.EINVAL
             if verbose: print(val)
         else:
             self.fail("expected exception")


More information about the Python-3000-checkins mailing list