Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
BTrees
Commits
1bf5f68b
Commit
1bf5f68b
authored
Nov 19, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage for _Tree._check.
parent
77f84f3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
1 deletion
+76
-1
BTrees/_base.py
BTrees/_base.py
+1
-1
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+75
-0
No files found.
BTrees/_base.py
View file @
1bf5f68b
...
@@ -973,7 +973,7 @@ class _Tree(_Base):
...
@@ -973,7 +973,7 @@ class _Tree(_Base):
for
i
in
data
:
for
i
in
data
:
assert_
(
i
.
child
is
not
None
,
"BTree has NULL child"
)
assert_
(
i
.
child
is
not
None
,
"BTree has NULL child"
)
assert_
(
i
.
child
.
__class__
is
child_class
,
assert_
(
i
.
child
.
__class__
is
child_class
,
"BTree children have different types"
)
;
"BTree children have different types"
)
assert_
(
i
.
child
.
size
,
"Bucket length < 1"
)
assert_
(
i
.
child
.
size
,
"Bucket length < 1"
)
if
child_class
is
self
.
__class__
:
if
child_class
is
self
.
__class__
:
...
...
BTrees/tests/test__base.py
View file @
1bf5f68b
...
@@ -1960,6 +1960,81 @@ class Test_Tree(unittest.TestCase):
...
@@ -1960,6 +1960,81 @@ class Test_Tree(unittest.TestCase):
self
.
assertEqual
(
tree
.
_data
[
1
].
child
,
b2
)
self
.
assertEqual
(
tree
.
_data
[
1
].
child
,
b2
)
self
.
assertTrue
(
tree
.
_firstbucket
is
b1
)
self
.
assertTrue
(
tree
.
_firstbucket
is
b1
)
def
test__check_empty_wo_firstbucket
(
self
):
tree
=
self
.
_makeOne
()
tree
.
_check
()
# no raise
def
test__check_empty_w_firstbucket
(
self
):
tree
=
self
.
_makeOne
()
tree
.
_firstbucket
=
object
()
e
=
self
.
assertRaises
(
AssertionError
,
tree
.
_check
)
self
.
assertEqual
(
str
(
e
),
"Empty BTree has non-NULL firstbucket"
)
def
test__check_nonempty_wo_firstbucket
(
self
):
tree
=
self
.
_makeOne
({
'a'
:
'b'
})
tree
.
_firstbucket
=
None
e
=
self
.
assertRaises
(
AssertionError
,
tree
.
_check
)
self
.
assertEqual
(
str
(
e
),
"Non-empty BTree has NULL firstbucket"
)
def
test__check_nonempty_w_null_child
(
self
):
tree
=
self
.
_makeOne
({
'a'
:
'b'
})
tree
.
_data
.
append
(
tree
.
_data
[
0
].
__class__
(
'c'
,
None
))
e
=
self
.
assertRaises
(
AssertionError
,
tree
.
_check
)
self
.
assertEqual
(
str
(
e
),
"BTree has NULL child"
)
def
test__check_nonempty_w_heterogenous_child
(
self
):
class
Other
(
object
):
pass
tree
=
self
.
_makeOne
({
'a'
:
'b'
})
tree
.
_data
.
append
(
tree
.
_data
[
0
].
__class__
(
'c'
,
Other
()))
e
=
self
.
assertRaises
(
AssertionError
,
tree
.
_check
)
self
.
assertEqual
(
str
(
e
),
"BTree children have different types"
)
def
test__check_nonempty_w_empty_child
(
self
):
tree
=
self
.
_makeOne
({
'a'
:
'b'
})
first
=
tree
.
_data
[
0
]
tree
.
_data
.
append
(
first
.
__class__
(
'c'
,
first
.
child
.
__class__
()))
e
=
self
.
assertRaises
(
AssertionError
,
tree
.
_check
)
self
.
assertEqual
(
str
(
e
),
"Bucket length < 1"
)
def
test__check_branch_w_mismatched_firstbucket
(
self
):
tree
=
self
.
_makeOne
()
c_tree
=
tree
.
__class__
({
'a'
:
'b'
})
c_first
=
c_tree
.
_data
[
0
]
tree
.
_data
.
append
(
c_first
.
__class__
(
'a'
,
c_tree
))
tree
.
_firstbucket
=
object
()
e
=
self
.
assertRaises
(
AssertionError
,
tree
.
_check
)
self
.
assertEqual
(
str
(
e
),
"BTree has firstbucket different than "
"its first child's firstbucket"
)
def
test__check_nonempty_w_invalid_child
(
self
):
class
Invalid
(
object
):
size
=
2
tree
=
self
.
_makeOne
({
'a'
:
'b'
})
tree
.
_data
[
0
].
child
=
Invalid
()
e
=
self
.
assertRaises
(
AssertionError
,
tree
.
_check
)
self
.
assertEqual
(
str
(
e
),
"Incorrect child type"
)
def
test__check_branch_traverse_bucket_pointers
(
self
):
tree
=
self
.
_makeOne
()
t_first
=
tree
.
__class__
({
'a'
:
'b'
})
c_first
=
t_first
.
_data
[
0
]
b_first
=
c_first
.
child
t_second
=
tree
.
__class__
({
'c'
:
'd'
})
b_first
.
_next
=
t_second
.
_firstbucket
tree
.
_data
.
append
(
c_first
.
__class__
(
'a'
,
t_first
))
tree
.
_data
.
append
(
c_first
.
__class__
(
'c'
,
t_second
))
tree
.
_firstbucket
=
t_first
.
_firstbucket
tree
.
_check
()
#no raise
def
test__check_nonempty_leaf_traverse_bucket_pointers
(
self
):
tree
=
self
.
_makeOne
({
'a'
:
'b'
})
first
=
tree
.
_data
[
0
]
first
.
child
.
_next
=
b2
=
first
.
child
.
__class__
({
'c'
:
'd'
})
tree
.
_data
.
append
(
first
.
__class__
(
'c'
,
b2
))
tree
.
_check
()
#no raise
class
_Jar
(
object
):
class
_Jar
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
...
...
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