summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-02-22 06:40:59 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-02-22 06:40:59 (GMT)
commit0072e43d295f25b709ced3b9f7a395fbd35d08e0 (patch)
tree4e9b05d6663f2312cb92fdc1da55cb44f357a877 /Lib/bsddb
parent5b8d24a7f74ce799efc4d77cf58d8e496635ef0d (diff)
downloadcpython-0072e43d295f25b709ced3b9f7a395fbd35d08e0.zip
cpython-0072e43d295f25b709ced3b9f7a395fbd35d08e0.tar.gz
cpython-0072e43d295f25b709ced3b9f7a395fbd35d08e0.tar.bz2
Fix test_bsddb3 (along with something bsddb) to work with dict views.
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/dbtables.py4
-rw-r--r--Lib/bsddb/test/test_dbtables.py10
2 files changed, 12 insertions, 2 deletions
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
index 5359de8..0e426d8 100644
--- a/Lib/bsddb/dbtables.py
+++ b/Lib/bsddb/dbtables.py
@@ -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
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
index c476e55..a7c2c27 100644
--- a/Lib/bsddb/test/test_dbtables.py
+++ b/Lib/bsddb/test/test_dbtables.py
@@ -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