mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Merge with bsddb3 2002.11.23.10.42.36
This commit is contained in:
parent
a797d8150d
commit
b2c7affbaa
6 changed files with 100 additions and 47 deletions
|
@ -210,7 +210,7 @@ class BTreeShelveTestCase(BasicShelveTestCase):
|
|||
|
||||
|
||||
class HashShelveTestCase(BasicShelveTestCase):
|
||||
dbtype = db.DB_BTREE
|
||||
dbtype = db.DB_HASH
|
||||
dbflags = db.DB_CREATE
|
||||
|
||||
|
||||
|
@ -220,7 +220,7 @@ class ThreadBTreeShelveTestCase(BasicShelveTestCase):
|
|||
|
||||
|
||||
class ThreadHashShelveTestCase(BasicShelveTestCase):
|
||||
dbtype = db.DB_BTREE
|
||||
dbtype = db.DB_HASH
|
||||
dbflags = db.DB_CREATE | db.DB_THREAD
|
||||
|
||||
|
||||
|
@ -261,7 +261,7 @@ class EnvBTreeShelveTestCase(BasicEnvShelveTestCase):
|
|||
|
||||
class EnvHashShelveTestCase(BasicEnvShelveTestCase):
|
||||
envflags = 0
|
||||
dbtype = db.DB_BTREE
|
||||
dbtype = db.DB_HASH
|
||||
dbflags = db.DB_CREATE
|
||||
|
||||
|
||||
|
@ -273,7 +273,7 @@ class EnvThreadBTreeShelveTestCase(BasicEnvShelveTestCase):
|
|||
|
||||
class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase):
|
||||
envflags = db.DB_THREAD
|
||||
dbtype = db.DB_BTREE
|
||||
dbtype = db.DB_HASH
|
||||
dbflags = db.DB_CREATE | db.DB_THREAD
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) 2000, 2001 by Autonomous Zone Industries
|
||||
# Copyright (C) 2002 Gregory P. Smith
|
||||
#
|
||||
# March 20, 2000
|
||||
#
|
||||
|
@ -159,6 +160,40 @@ class TableDBTestCase(unittest.TestCase):
|
|||
assert values[0]['b'] == "bad"
|
||||
|
||||
|
||||
def test04_MultiCondSelect(self):
|
||||
tabname = "test04_MultiCondSelect"
|
||||
try:
|
||||
self.tdb.Drop(tabname)
|
||||
except dbtables.TableDBError:
|
||||
pass
|
||||
self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
|
||||
|
||||
try:
|
||||
self.tdb.Insert(tabname, {'a': "", 'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1), 'f': "Zero"})
|
||||
assert 0
|
||||
except dbtables.TableDBError:
|
||||
pass
|
||||
|
||||
self.tdb.Insert(tabname, {'a': "A", 'b': "B", 'c': "C", 'd': "D", 'e': "E"})
|
||||
self.tdb.Insert(tabname, {'a': "-A", 'b': "-B", 'c': "-C", 'd': "-D", 'e': "-E"})
|
||||
self.tdb.Insert(tabname, {'a': "A-", 'b': "B-", 'c': "C-", 'd': "D-", 'e': "E-"})
|
||||
|
||||
if verbose:
|
||||
self.tdb._db_print()
|
||||
|
||||
# This select should return 0 rows. it is designed to test
|
||||
# the bug identified and fixed in sourceforge bug # 590449
|
||||
# (Big Thanks to "Rob Tillotson (n9mtb)" for tracking this down
|
||||
# and supplying a fix!! This one caused many headaches to say
|
||||
# the least...)
|
||||
values = self.tdb.Select(tabname, ['b', 'a', 'd'],
|
||||
conditions={'e': dbtables.ExactCond('E'),
|
||||
'a': dbtables.ExactCond('A'),
|
||||
'd': dbtables.PrefixCond('-')
|
||||
} )
|
||||
assert len(values) == 0, values
|
||||
|
||||
|
||||
def test_CreateOrExtend(self):
|
||||
tabname = "test_CreateOrExtend"
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ except ImportError:
|
|||
import unittest
|
||||
from test.test_support import verbose
|
||||
|
||||
from bsddb import db
|
||||
from bsddb import db, dbutils
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -31,6 +31,9 @@ class BaseThreadedTestCase(unittest.TestCase):
|
|||
|
||||
|
||||
def setUp(self):
|
||||
if verbose:
|
||||
dbutils._deadlock_VerboseFile = sys.stdout
|
||||
|
||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
||||
self.homeDir = homeDir
|
||||
try: os.mkdir(homeDir)
|
||||
|
@ -109,7 +112,7 @@ class ConcurrentDataStoreBase(BaseThreadedTestCase):
|
|||
|
||||
for x in range(start, stop):
|
||||
key = '%04d' % x
|
||||
d.put(key, self.makeData(key))
|
||||
dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
|
||||
if verbose and x % 100 == 0:
|
||||
print "%s: records %d - %d finished" % (name, start, x)
|
||||
|
||||
|
@ -212,7 +215,7 @@ class SimpleThreadedBase(BaseThreadedTestCase):
|
|||
# create a bunch of records
|
||||
for x in xrange(start, stop):
|
||||
key = '%04d' % x
|
||||
d.put(key, self.makeData(key))
|
||||
dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
|
||||
|
||||
if verbose and x % 100 == 0:
|
||||
print "%s: records %d - %d finished" % (name, start, x)
|
||||
|
@ -221,12 +224,12 @@ class SimpleThreadedBase(BaseThreadedTestCase):
|
|||
if random() <= 0.05:
|
||||
for y in xrange(start, x):
|
||||
key = '%04d' % x
|
||||
data = d.get(key)
|
||||
data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
|
||||
assert data == self.makeData(key)
|
||||
|
||||
# flush them
|
||||
try:
|
||||
d.sync()
|
||||
dbutils.DeadlockWrap(d.sync, max_retries=12)
|
||||
except db.DBIncompleteError, val:
|
||||
if verbose:
|
||||
print "could not complete sync()..."
|
||||
|
@ -234,12 +237,12 @@ class SimpleThreadedBase(BaseThreadedTestCase):
|
|||
# read them back, deleting a few
|
||||
for x in xrange(start, stop):
|
||||
key = '%04d' % x
|
||||
data = d.get(key)
|
||||
data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
|
||||
if verbose and x % 100 == 0:
|
||||
print "%s: fetched record (%s, %s)" % (name, key, data)
|
||||
assert data == self.makeData(key)
|
||||
assert data == self.makeData(key), (key, data, self.makeData(key))
|
||||
if random() <= 0.10:
|
||||
d.delete(key)
|
||||
dbutils.DeadlockWrap(d.delete, key, max_retries=12)
|
||||
if verbose:
|
||||
print "%s: deleted record %s" % (name, key)
|
||||
|
||||
|
@ -273,7 +276,7 @@ class BTreeSimpleThreaded(SimpleThreadedBase):
|
|||
|
||||
|
||||
class HashSimpleThreaded(SimpleThreadedBase):
|
||||
dbtype = db.DB_BTREE
|
||||
dbtype = db.DB_HASH
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue