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
8d2a9b25
Commit
8d2a9b25
authored
Dec 17, 2014
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BTrees._base: 100% branch coverage.
parent
e2527094
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
1 deletion
+69
-1
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+69
-1
No files found.
BTrees/tests/test__base.py
View file @
8d2a9b25
...
...
@@ -597,6 +597,19 @@ class BucketTests(unittest.TestCase):
self
.
assertTrue
(
bucket
.
_next
is
new_b
)
self
.
assertTrue
(
new_b
.
_next
is
next_b
)
def
test__split_filled_explicit_index
(
self
):
bucket
=
self
.
_makeOne
()
next_b
=
bucket
.
_next
=
self
.
_makeOne
()
for
i
,
c
in
enumerate
(
'abcdef'
):
bucket
[
c
]
=
i
new_b
=
bucket
.
_split
(
2
)
self
.
assertEqual
(
list
(
bucket
.
_keys
),
[
'a'
,
'b'
])
self
.
assertEqual
(
list
(
bucket
.
_values
),
[
0
,
1
])
self
.
assertEqual
(
list
(
new_b
.
_keys
),
[
'c'
,
'd'
,
'e'
,
'f'
])
self
.
assertEqual
(
list
(
new_b
.
_values
),
[
2
,
3
,
4
,
5
])
self
.
assertTrue
(
bucket
.
_next
is
new_b
)
self
.
assertTrue
(
new_b
.
_next
is
next_b
)
def
test_keys_empty_no_args
(
self
):
bucket
=
self
.
_makeOne
()
self
.
assertEqual
(
bucket
.
keys
(),
[])
...
...
@@ -764,6 +777,17 @@ class BucketTests(unittest.TestCase):
self
.
assertEqual
(
bucket
.
items
(),
EXPECTED
)
self
.
assertTrue
(
bucket
.
_next
is
next_b
)
def
test__p_resolveConflict_x_on_com_next_old_new_None
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_makeOne
()
N_NEW
=
object
()
s_old
=
None
s_com
=
((),
N_NEW
)
s_new
=
None
e
=
self
.
assertRaises
(
BTreesConflictError
,
bucket
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_x_on_com_next
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_makeOne
()
...
...
@@ -775,6 +799,17 @@ class BucketTests(unittest.TestCase):
bucket
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_x_on_new_next_old_com_None
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_makeOne
()
N_NEW
=
object
()
s_old
=
None
s_com
=
None
s_new
=
((),
N_NEW
)
e
=
self
.
assertRaises
(
BTreesConflictError
,
bucket
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_x_on_new_next
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_makeOne
()
...
...
@@ -1151,6 +1186,28 @@ class SetTests(unittest.TestCase):
self
.
assertTrue
(
_set
.
_next
is
new_b
)
self
.
assertTrue
(
new_b
.
_next
is
next_b
)
def
test__split_filled_explicit_index
(
self
):
_set
=
self
.
_makeOne
()
next_b
=
_set
.
_next
=
self
.
_makeOne
()
for
c
in
'abcdef'
:
_set
.
add
(
c
)
new_b
=
_set
.
_split
(
2
)
self
.
assertEqual
(
list
(
_set
.
_keys
),
[
'a'
,
'b'
])
self
.
assertEqual
(
list
(
new_b
.
_keys
),
[
'c'
,
'd'
,
'e'
,
'f'
])
self
.
assertTrue
(
_set
.
_next
is
new_b
)
self
.
assertTrue
(
new_b
.
_next
is
next_b
)
def
test__p_resolveConflict_x_on_com_next_old_new_None
(
self
):
from
..Interfaces
import
BTreesConflictError
_set
=
self
.
_makeOne
()
N_NEW
=
object
()
s_old
=
None
s_com
=
((),
N_NEW
)
s_new
=
None
e
=
self
.
assertRaises
(
BTreesConflictError
,
_set
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_x_on_com_next
(
self
):
from
..Interfaces
import
BTreesConflictError
_set
=
self
.
_makeOne
()
...
...
@@ -1162,6 +1219,17 @@ class SetTests(unittest.TestCase):
_set
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_x_on_new_next_old_com_None
(
self
):
from
..Interfaces
import
BTreesConflictError
_set
=
self
.
_makeOne
()
N_NEW
=
object
()
s_old
=
None
s_com
=
None
s_new
=
((),
N_NEW
)
e
=
self
.
assertRaises
(
BTreesConflictError
,
_set
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_x_on_new_next
(
self
):
from
..Interfaces
import
BTreesConflictError
_set
=
self
.
_makeOne
()
...
...
@@ -1831,7 +1899,7 @@ class Test_Tree(unittest.TestCase):
tree
[
key
]
=
i
KEYS
.
append
(
key
)
fb
=
tree
.
_firstbucket
new_t
=
tree
.
_split
()
new_t
=
tree
.
_split
(
tree
.
max_internal_size
-
2
)
# Note that original tree still links to split buckets
self
.
assertEqual
(
list
(
tree
),
KEYS
)
self
.
assertTrue
(
tree
.
_firstbucket
is
fb
)
...
...
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