Commit 2043513b authored by Guido van Rossum's avatar Guido van Rossum

Fixed to the point that all unit tests pass again. (However, I get 4

"exception in thread" messages, one about a killed locker, and three
assertions.)  Details:

test/test_dbshelve.py:
- kill reference to InstanceType

test/test_basics.py:
- use // for int division
- use 'in' instead of has_key

dbshelve.py:
- fix bug in previous has_key fix, use self.db.has_key instead of self.has_key

dbtables.py:
- use 'in' instead of has_key

dbutils.py:
- fix bug in previous has_key fix, test for 'max_retries', not 'max_tries'
parent f1a69c16
...@@ -198,7 +198,7 @@ class DBShelf(DictMixin): ...@@ -198,7 +198,7 @@ class DBShelf(DictMixin):
def __contains__(self, key): def __contains__(self, key):
return self.has_key(key) return self.db.has_key(key)
#---------------------------------------------- #----------------------------------------------
......
...@@ -323,7 +323,7 @@ class bsdTableDB : ...@@ -323,7 +323,7 @@ class bsdTableDB :
# column names # column names
newcolumnlist = copy.copy(oldcolumnlist) newcolumnlist = copy.copy(oldcolumnlist)
for c in columns: for c in columns:
if not oldcolumnhash.has_key(c): if c not in oldcolumnhash:
newcolumnlist.append(c) newcolumnlist.append(c)
# store the table's new extended column list # store the table's new extended column list
...@@ -389,7 +389,7 @@ class bsdTableDB : ...@@ -389,7 +389,7 @@ class bsdTableDB :
raise TableDBError, "unknown table" raise TableDBError, "unknown table"
# check the validity of each column name # check the validity of each column name
if not self.__tablecolumns.has_key(table): if table not in self.__tablecolumns:
self.__load_column_info(table) self.__load_column_info(table)
for column in rowdict.keys() : for column in rowdict.keys() :
if not self.__tablecolumns[table].count(column): if not self.__tablecolumns[table].count(column):
...@@ -521,7 +521,7 @@ class bsdTableDB : ...@@ -521,7 +521,7 @@ class bsdTableDB :
argument and returning a boolean. argument and returning a boolean.
""" """
try: try:
if not self.__tablecolumns.has_key(table): if table not in self.__tablecolumns:
self.__load_column_info(table) self.__load_column_info(table)
if columns is None: if columns is None:
columns = self.__tablecolumns[table] columns = self.__tablecolumns[table]
...@@ -542,7 +542,7 @@ class bsdTableDB : ...@@ -542,7 +542,7 @@ class bsdTableDB :
argument and returning a boolean. argument and returning a boolean.
""" """
# check the validity of each column name # check the validity of each column name
if not self.__tablecolumns.has_key(table): if table not in self.__tablecolumns:
self.__load_column_info(table) self.__load_column_info(table)
if columns is None: if columns is None:
columns = self.tablecolumns[table] columns = self.tablecolumns[table]
...@@ -601,16 +601,16 @@ class bsdTableDB : ...@@ -601,16 +601,16 @@ class bsdTableDB :
# extract the rowid from the key # extract the rowid from the key
rowid = key[-_rowid_str_len:] rowid = key[-_rowid_str_len:]
if not rejected_rowids.has_key(rowid): if rowid not in rejected_rowids:
# if no condition was specified or the condition # if no condition was specified or the condition
# succeeds, add row to our match list. # succeeds, add row to our match list.
if not condition or condition(data): if not condition or condition(data):
if not matching_rowids.has_key(rowid): if rowid not in matching_rowids:
matching_rowids[rowid] = {} matching_rowids[rowid] = {}
if savethiscolumndata: if savethiscolumndata:
matching_rowids[rowid][column] = data matching_rowids[rowid][column] = data
else: else:
if matching_rowids.has_key(rowid): if rowid in matching_rowids:
del matching_rowids[rowid] del matching_rowids[rowid]
rejected_rowids[rowid] = rowid rejected_rowids[rowid] = rowid
...@@ -631,7 +631,7 @@ class bsdTableDB : ...@@ -631,7 +631,7 @@ class bsdTableDB :
if len(columns) > 0: if len(columns) > 0:
for rowid, rowdata in matching_rowids.items(): for rowid, rowdata in matching_rowids.items():
for column in columns: for column in columns:
if rowdata.has_key(column): if column in rowdata:
continue continue
try: try:
rowdata[column] = self.db.get( rowdata[column] = self.db.get(
...@@ -697,7 +697,7 @@ class bsdTableDB : ...@@ -697,7 +697,7 @@ class bsdTableDB :
txn.commit() txn.commit()
txn = None txn = None
if self.__tablecolumns.has_key(table): if table in self.__tablecolumns:
del self.__tablecolumns[table] del self.__tablecolumns[table]
except DBError, dberror: except DBError, dberror:
......
...@@ -55,7 +55,7 @@ def DeadlockWrap(function, *_args, **_kwargs): ...@@ -55,7 +55,7 @@ def DeadlockWrap(function, *_args, **_kwargs):
""" """
sleeptime = _deadlock_MinSleepTime sleeptime = _deadlock_MinSleepTime
max_retries = _kwargs.get('max_retries', -1) max_retries = _kwargs.get('max_retries', -1)
if 'max_tries' in _kwargs: if 'max_retries' in _kwargs:
del _kwargs['max_retries'] del _kwargs['max_retries']
while True: while True:
try: try:
......
...@@ -114,14 +114,14 @@ class BasicTestCase(unittest.TestCase): ...@@ -114,14 +114,14 @@ class BasicTestCase(unittest.TestCase):
def populateDB(self, _txn=None): def populateDB(self, _txn=None):
d = self.d d = self.d
for x in range(self._numKeys/2): for x in range(self._numKeys//2):
key = '%04d' % (self._numKeys - x) # insert keys in reverse order key = '%04d' % (self._numKeys - x) # insert keys in reverse order
data = self.makeData(key) data = self.makeData(key)
d.put(key, data, _txn) d.put(key, data, _txn)
d.put('empty value', '', _txn) d.put('empty value', '', _txn)
for x in range(self._numKeys/2-1): for x in range(self._numKeys//2-1):
key = '%04d' % x # and now some in forward order key = '%04d' % x # and now some in forward order
data = self.makeData(key) data = self.makeData(key)
d.put(key, data, _txn) d.put(key, data, _txn)
...@@ -686,10 +686,10 @@ class BasicTransactionTestCase(BasicTestCase): ...@@ -686,10 +686,10 @@ class BasicTransactionTestCase(BasicTestCase):
if db.version() >= (4,0): if db.version() >= (4,0):
statDict = self.env.log_stat(0); statDict = self.env.log_stat(0);
assert statDict.has_key('magic') assert 'magic' in statDict
assert statDict.has_key('version') assert 'version' in statDict
assert statDict.has_key('cur_file') assert 'cur_file' in statDict
assert statDict.has_key('region_nowait') assert 'region_nowait' in statDict
# must have at least one log file present: # must have at least one log file present:
logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG) logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG)
......
...@@ -187,7 +187,6 @@ class DBShelveTestCase(unittest.TestCase): ...@@ -187,7 +187,6 @@ class DBShelveTestCase(unittest.TestCase):
assert value == [x] * 10 assert value == [x] * 10
elif key[0] == 'O': elif key[0] == 'O':
assert type(value) == InstanceType
assert value.S == 10 * x assert value.S == 10 * x
assert value.I == ord(x) assert value.I == ord(x)
assert value.L == [x] * 10 assert value.L == [x] * 10
......
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