summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2005-06-04 06:46:59 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2005-06-04 06:46:59 (GMT)
commite947706b10b8ac9d01cb9d6246d962f1f24895a4 (patch)
treea4983bbe19c90bee8c0c866b371f34debcc7d19b /Lib/bsddb
parent5d36a55eaa55d34bfaf91135920688d0cbc6fc5f (diff)
downloadcpython-e947706b10b8ac9d01cb9d6246d962f1f24895a4.zip
cpython-e947706b10b8ac9d01cb9d6246d962f1f24895a4.tar.gz
cpython-e947706b10b8ac9d01cb9d6246d962f1f24895a4.tar.bz2
pybsddb 4.3.2:
* the has_key() method was not raising a DBError when a database error had occurred. [SF patch id 1212590] * added a wrapper for the DBEnv.set_lg_regionmax method [SF patch id 1212590] * DBKeyEmptyError now derives from KeyError just like DBNotFoundError. * internally everywhere DB_NOTFOUND was checked for has been updated to also check for DB_KEYEMPTY. This fixes the semantics of a couple operations on recno and queue databases to be more intuitive and results in less unexpected DBKeyEmptyError exceptions being raised.
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/test/test_basics.py11
-rw-r--r--Lib/bsddb/test/test_recno.py31
2 files changed, 33 insertions, 9 deletions
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index 155705d..d3bbb4f 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -397,10 +397,14 @@ class BasicTestCase(unittest.TestCase):
try:
rec = c.current()
except db.DBKeyEmptyError, val:
- assert val[0] == db.DB_KEYEMPTY
- if verbose: print val
+ if get_raises_error:
+ assert val[0] == db.DB_KEYEMPTY
+ if verbose: print val
+ else:
+ self.fail("unexpected DBKeyEmptyError")
else:
- self.fail('exception expected')
+ if get_raises_error:
+ self.fail('DBKeyEmptyError exception expected')
c.next()
c2 = c.dup(db.DB_POSITION)
@@ -612,7 +616,6 @@ class BasicTransactionTestCase(BasicTestCase):
self.txn = self.env.txn_begin()
-
def test06_Transactions(self):
d = self.d
if verbose:
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index 56a79c7..a46a0c5 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -34,6 +34,10 @@ class SimpleRecnoTestCase(unittest.TestCase):
def test01_basic(self):
d = db.DB()
+
+ get_returns_none = d.set_get_returns_none(2)
+ d.set_get_returns_none(get_returns_none)
+
d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
for x in letters:
@@ -65,6 +69,14 @@ class SimpleRecnoTestCase(unittest.TestCase):
else:
self.fail("expected exception")
+ # test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
+ try:
+ d.has_key(0)
+ except db.DBError, val:
+ pass
+ else:
+ self.fail("has_key did not raise a proper exception")
+
try:
data = d[100]
except KeyError:
@@ -72,8 +84,13 @@ class SimpleRecnoTestCase(unittest.TestCase):
else:
self.fail("expected exception")
- data = d.get(100)
- assert data == None
+ try:
+ data = d.get(100)
+ except db.DBNotFoundError, val:
+ if get_returns_none:
+ self.fail("unexpected exception")
+ else:
+ assert data == None
keys = d.keys()
if verbose:
@@ -161,10 +178,14 @@ class SimpleRecnoTestCase(unittest.TestCase):
try:
d.get(99)
except db.DBKeyEmptyError, val:
- assert val[0] == db.DB_KEYEMPTY
- if verbose: print val
+ if get_returns_none:
+ self.fail("unexpected DBKeyEmptyError exception")
+ else:
+ assert val[0] == db.DB_KEYEMPTY
+ if verbose: print val
else:
- self.fail("expected exception")
+ if not get_returns_none:
+ self.fail("expected exception")
rec = c.set(40)
while rec: