Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0072e43d
Commit
0072e43d
authored
Feb 22, 2007
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test_bsddb3 (along with something bsddb) to work with dict views.
parent
5b8d24a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
BROKEN
BROKEN
+1
-1
Lib/bsddb/dbtables.py
Lib/bsddb/dbtables.py
+2
-2
Lib/bsddb/test/test_dbtables.py
Lib/bsddb/test/test_dbtables.py
+10
-0
No files found.
BROKEN
View file @
0072e43d
test_bsddb test_
bsddb3 test_
compile
test_bsddb test_compile
Lib/bsddb/dbtables.py
View file @
0072e43d
...
...
@@ -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
...
...
Lib/bsddb/test/test_dbtables.py
View file @
0072e43d
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment