Commit 0072e43d authored by Brett Cannon's avatar Brett Cannon

Fix test_bsddb3 (along with something bsddb) to work with dict views.

parent 5b8d24a7
test_bsddb test_bsddb3 test_compile
test_bsddb test_compile
......@@ -546,7 +546,7 @@ class bsdTableDB :
self.__load_column_info(table)
if columns is None:
columns = self.tablecolumns[table]
for column in (columns + conditions.keys()):
for column in (columns + list(conditions.keys())):
if not self.__tablecolumns[table].count(column):
raise TableDBError, "unknown column: %r" % (column,)
......@@ -580,7 +580,7 @@ class bsdTableDB :
# leave all unknown condition callables alone as equals
return 0
conditionlist = conditions.items()
conditionlist = list(conditions.items())
conditionlist.sort(cmp_conditions)
# Apply conditions to column data to find what we want
......
......@@ -76,6 +76,7 @@ class TableDBTestCase(unittest.TestCase):
values = self.tdb.Select(
tabname, [colname], conditions={colname: None})
values = list(values)
colval = pickle.loads(values[0][colname])
assert(colval > 3.141 and colval < 3.142)
......@@ -102,6 +103,7 @@ class TableDBTestCase(unittest.TestCase):
values = self.tdb.Select(tabname, [col2],
conditions={col0: lambda x: pickle.loads(x) >= 8})
values = list(values)
assert len(values) == 2
if values[0]['Species'] == 'Penguin' :
......@@ -179,11 +181,13 @@ class TableDBTestCase(unittest.TestCase):
values = self.tdb.Select(
tabname, ['a', 'd', 'b'],
conditions={'e': dbtables.PrefixCond('Fuzzy')})
values = list(values)
assert len(values) == 1
assert values[0]['d'] == None
values = self.tdb.Select(tabname, ['b'],
conditions={'c': lambda c: c == 'meep'})
values = list(values)
assert len(values) == 1
assert values[0]['b'] == "bad"
......@@ -272,6 +276,7 @@ class TableDBTestCase(unittest.TestCase):
values = self.tdb.Select(
tabname, ['p', 'e'],
conditions={'e': dbtables.PrefixCond('the l')})
values = list(values)
assert len(values) == 2, values
assert values[0]['e'] == values[1]['e'], values
assert values[0]['p'] != values[1]['p'], values
......@@ -279,6 +284,7 @@ class TableDBTestCase(unittest.TestCase):
values = self.tdb.Select(
tabname, ['d', 'a'],
conditions={'a': dbtables.LikeCond('%aardvark%')})
values = list(values)
assert len(values) == 1, values
assert values[0]['d'] == "is for dog", values
assert values[0]['a'] == "is for aardvark", values
......@@ -290,6 +296,7 @@ class TableDBTestCase(unittest.TestCase):
'd':dbtables.ExactCond('is for dog'),
'c':dbtables.PrefixCond('is for'),
'p':lambda s: not s})
values = list(values)
assert len(values) == 1, values
assert values[0]['d'] == "is for dog", values
assert values[0]['a'] == "is for aardvark", values
......@@ -354,6 +361,7 @@ class TableDBTestCase(unittest.TestCase):
values = self.tdb.Select(
tabname, None,
conditions={'Type': dbtables.ExactCond('Unknown')})
values = list(values)
assert len(values) == 1, values
assert values[0]['Name'] == None, values
assert values[0]['Access'] == None, values
......@@ -362,6 +370,7 @@ class TableDBTestCase(unittest.TestCase):
values = self.tdb.Select(
tabname, None,
conditions={'Name': dbtables.ExactCond('Nifty.MP3')})
values = list(values)
assert len(values) == 1, values
assert values[0]['Type'] == "MP3", values
assert values[0]['Access'] == "2", values
......@@ -369,6 +378,7 @@ class TableDBTestCase(unittest.TestCase):
# Make sure change applied only to select conditions
values = self.tdb.Select(
tabname, None, conditions={'Name': dbtables.LikeCond('%doc%')})
values = list(values)
assert len(values) == 1, values
assert values[0]['Type'] == "Word", values
assert values[0]['Access'] == "9", values
......
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