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
ec035b4d
Commit
ec035b4d
authored
Dec 04, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage for BTrees.check.crack_btree.
parent
dff3fcce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
BTrees/tests/test_check.py
BTrees/tests/test_check.py
+51
-0
No files found.
BTrees/tests/test_check.py
View file @
ec035b4d
...
@@ -54,6 +54,45 @@ class Test_classify(unittest.TestCase):
...
@@ -54,6 +54,45 @@ class Test_classify(unittest.TestCase):
self
.
assertFalse
(
is_mapping
)
self
.
assertFalse
(
is_mapping
)
class
Test_crack_btree
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
obj
,
is_mapping
):
from
BTrees.check
import
crack_btree
return
crack_btree
(
obj
,
is_mapping
)
def
test_w_empty_tree
(
self
):
from
BTrees.check
import
BTREE_EMPTY
class
Empty
(
object
):
def
__getstate__
(
self
):
return
None
kind
,
keys
,
kids
=
self
.
_callFUT
(
Empty
(),
True
)
self
.
assertEqual
(
kind
,
BTREE_EMPTY
)
self
.
assertEqual
(
keys
,
[])
self
.
assertEqual
(
kids
,
[])
def
test_w_degenerate_tree
(
self
):
from
BTrees.check
import
BTREE_ONE
class
Degenerate
(
object
):
def
__getstate__
(
self
):
return
(((
'a'
,
1
,
'b'
,
2
),),)
kind
,
keys
,
kids
=
self
.
_callFUT
(
Degenerate
(),
True
)
self
.
assertEqual
(
kind
,
BTREE_ONE
)
self
.
assertEqual
(
keys
,
(
'a'
,
1
,
'b'
,
2
))
self
.
assertEqual
(
kids
,
None
)
def
test_w_normal_tree
(
self
):
from
BTrees.check
import
BTREE_NORMAL
first_bucket
=
[
object
()]
*
8
second_bucket
=
[
object
()]
*
8
class
Normal
(
object
):
def
__getstate__
(
self
):
return
((
first_bucket
,
'b'
,
second_bucket
),
first_bucket
)
kind
,
keys
,
kids
=
self
.
_callFUT
(
Normal
(),
True
)
self
.
assertEqual
(
kind
,
BTREE_NORMAL
)
self
.
assertEqual
(
keys
,
[
'b'
])
self
.
assertEqual
(
kids
,
[
first_bucket
,
second_bucket
])
class
Test_check
(
unittest
.
TestCase
):
class
Test_check
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
tree
):
def
_callFUT
(
self
,
tree
):
...
@@ -138,8 +177,20 @@ class Test_check(unittest.TestCase):
...
@@ -138,8 +177,20 @@ class Test_check(unittest.TestCase):
self
.
fail
(
"expected check(tree) to catch the problem"
)
self
.
fail
(
"expected check(tree) to catch the problem"
)
class
Test_helpers
(
unittest
.
TestCase
):
def
test_type_and_adr_w_oid
(
self
):
from
BTrees.check
import
type_and_adr
class
WOid
(
object
):
_p_oid
=
'DEADBEEF'
t_and_a
=
type_and_adr
(
WOid
())
self
.
assertTrue
(
t_and_a
.
startswith
(
'WOid'
))
def
test_suite
():
def
test_suite
():
return
unittest
.
TestSuite
((
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
Test_classify
),
unittest
.
makeSuite
(
Test_classify
),
unittest
.
makeSuite
(
Test_crack_btree
),
unittest
.
makeSuite
(
Test_check
),
unittest
.
makeSuite
(
Test_check
),
unittest
.
makeSuite
(
Test_helpers
),
))
))
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