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
477ed6b3
Commit
477ed6b3
authored
Dec 04, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start coverage for set operations.
parent
bbe21e43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+86
-0
No files found.
BTrees/tests/test__base.py
View file @
477ed6b3
...
@@ -2410,6 +2410,60 @@ class TreeSetTests(unittest.TestCase):
...
@@ -2410,6 +2410,60 @@ class TreeSetTests(unittest.TestCase):
self
.
assertTrue
(
letter
in
_set
)
self
.
assertTrue
(
letter
in
_set
)
class
_SetObBase
(
object
):
def
_makeSet
(
self
,
*
args
):
return
_Set
(
*
args
)
def
_makeMapping
(
self
,
*
args
,
**
kw
):
return
_Mapping
(
*
args
,
**
kw
)
class
Test_difference
(
unittest
.
TestCase
,
_SetObBase
):
def
_callFUT
(
self
,
*
args
,
**
kw
):
from
.._base
import
difference
return
difference
(
*
args
,
**
kw
)
def
test_lhs_none
(
self
):
rhs
=
self
.
_makeSet
((
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
self
.
_callFUT
(
rhs
.
__class__
,
None
,
rhs
),
None
)
def
test_rhs_none
(
self
):
lhs
=
self
.
_makeSet
((
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
None
),
lhs
)
class
Test_union
(
unittest
.
TestCase
,
_SetObBase
):
def
_callFUT
(
self
,
*
args
,
**
kw
):
from
.._base
import
union
return
union
(
*
args
,
**
kw
)
def
test_lhs_none
(
self
):
rhs
=
self
.
_makeSet
((
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
self
.
_callFUT
(
rhs
.
__class__
,
None
,
rhs
),
rhs
)
def
test_rhs_none
(
self
):
lhs
=
self
.
_makeSet
((
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
None
),
lhs
)
class
Test_intersection
(
unittest
.
TestCase
,
_SetObBase
):
def
_callFUT
(
self
,
*
args
,
**
kw
):
from
.._base
import
intersection
return
intersection
(
*
args
,
**
kw
)
def
test_lhs_none
(
self
):
rhs
=
self
.
_makeSet
((
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
self
.
_callFUT
(
rhs
.
__class__
,
None
,
rhs
),
rhs
)
def
test_rhs_none
(
self
):
lhs
=
self
.
_makeSet
((
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
None
),
lhs
)
class
_Jar
(
object
):
class
_Jar
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
_current
=
set
()
self
.
_current
=
set
()
...
@@ -2419,6 +2473,35 @@ class _Jar(object):
...
@@ -2419,6 +2473,35 @@ class _Jar(object):
pass
pass
class
_Set
(
object
):
def
__init__
(
self
,
*
args
,
**
kw
):
keys
=
set
(
args
)
self
.
_keys
=
sorted
(
keys
)
def
keys
(
self
):
return
self
.
_keys
def
__iter__
(
self
):
return
iter
(
self
.
_keys
)
_Set
.
_set_type
=
_Set
class
_Mapping
(
dict
):
def
__init__
(
self
,
source
=
None
):
if
source
is
None
:
source
=
{}
self
.
_keys
=
[]
self
.
_values
=
[]
for
k
,
v
in
sorted
(
source
.
items
()):
self
.
_keys
.
append
(
k
)
self
.
_values
.
append
(
k
)
def
MERGE_WEIGHT
(
self
,
v
,
w
):
return
v
def
iteritems
(
self
):
for
k
,
v
in
zip
(
self
.
_keys
,
self
.
_values
):
yield
k
,
v
_Mapping
.
_set_type
=
_Set
_Mapping
.
_mapping_type
=
_Mapping
def
test_suite
():
def
test_suite
():
return
unittest
.
TestSuite
((
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
Test_Base
),
unittest
.
makeSuite
(
Test_Base
),
...
@@ -2431,4 +2514,7 @@ def test_suite():
...
@@ -2431,4 +2514,7 @@ def test_suite():
unittest
.
makeSuite
(
Test_TreeItems
),
unittest
.
makeSuite
(
Test_TreeItems
),
unittest
.
makeSuite
(
TreeTests
),
unittest
.
makeSuite
(
TreeTests
),
unittest
.
makeSuite
(
TreeSetTests
),
unittest
.
makeSuite
(
TreeSetTests
),
unittest
.
makeSuite
(
Test_difference
),
unittest
.
makeSuite
(
Test_union
),
unittest
.
makeSuite
(
Test_intersection
),
))
))
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