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
789b6380
Commit
789b6380
authored
Nov 19, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage for _TreeItems.
parent
a7645764
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+83
-0
No files found.
BTrees/tests/test__base.py
View file @
789b6380
...
@@ -2132,6 +2132,88 @@ class Test_Tree(unittest.TestCase):
...
@@ -2132,6 +2132,88 @@ class Test_Tree(unittest.TestCase):
self
.
assertEqual
(
resolved
,
((((
'a'
,
'b'
,
'e'
,
'f'
),),),))
self
.
assertEqual
(
resolved
,
((((
'a'
,
'b'
,
'e'
,
'f'
),),),))
class
Test_TreeItems
(
unittest
.
TestCase
):
assertRaises
=
_assertRaises
def
_getTargetClass
(
self
):
from
.._base
import
_TreeItems
return
_TreeItems
def
_makeOne
(
self
,
firstbucket
,
itertype
,
iterargs
):
return
self
.
_getTargetClass
()(
firstbucket
,
itertype
,
iterargs
)
def
_makeBucket
(
self
,
items
=
None
):
from
.._base
import
Bucket
class
_Bucket
(
Bucket
):
MAX_SIZE
=
10
def
_to_key
(
self
,
k
):
return
k
return
_Bucket
(
items
)
def
test___getitem___w_slice
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'iterkeys'
,
())
self
.
assertEqual
(
list
(
ti
[
0
:
3
]),
[
'a'
,
'b'
,
'c'
])
def
test___getitem___w_negative_index_le_minus_length
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'iterkeys'
,
())
def
_should_error
():
return
ti
[
-
27
]
self
.
assertRaises
(
IndexError
,
_should_error
)
def
test___getitem___w_index_gt_length
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'iterkeys'
,
())
def
_should_error
():
return
ti
[
27
]
self
.
assertRaises
(
IndexError
,
_should_error
)
def
test___getitem___w_index_smaller_than_cursor
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'iterkeys'
,
())
ti
[
12
]
self
.
assertEqual
(
ti
[
1
],
'b'
)
def
test___len__
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'iterkeys'
,
())
self
.
assertEqual
(
len
(
ti
),
26
)
# short-circuit on second pass
self
.
assertEqual
(
len
(
ti
),
26
)
def
test___iter___w_iterkeys
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'iterkeys'
,
())
self
.
assertEqual
(
list
(
ti
),
[
x
[
0
]
for
x
in
ITEMS
])
def
test___iter___w_iteritems
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'iteritems'
,
())
self
.
assertEqual
(
list
(
ti
),
ITEMS
)
def
test___iter___w_itervalues
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket
=
self
.
_makeBucket
(
ITEMS
)
ti
=
self
.
_makeOne
(
bucket
,
'itervalues'
,
())
self
.
assertEqual
(
list
(
ti
),
[
x
[
1
]
for
x
in
ITEMS
])
def
test___iter___w_empty_last_bucket
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
bucket1
=
self
.
_makeBucket
(
ITEMS
)
bucket2
=
bucket1
.
_next
=
self
.
_makeBucket
()
ti
=
self
.
_makeOne
(
bucket1
,
'iterkeys'
,
())
self
.
assertEqual
(
list
(
ti
),
[
x
[
0
]
for
x
in
ITEMS
])
class
_Jar
(
object
):
class
_Jar
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
_current
=
set
()
self
.
_current
=
set
()
...
@@ -2150,4 +2232,5 @@ def test_suite():
...
@@ -2150,4 +2232,5 @@ def test_suite():
unittest
.
makeSuite
(
SetTests
),
unittest
.
makeSuite
(
SetTests
),
unittest
.
makeSuite
(
Test_TreeItem
),
unittest
.
makeSuite
(
Test_TreeItem
),
unittest
.
makeSuite
(
Test_Tree
),
unittest
.
makeSuite
(
Test_Tree
),
unittest
.
makeSuite
(
Test_TreeItems
),
))
))
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