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
ea252991
Commit
ea252991
authored
Dec 04, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage for BTrees._base.difference.
parent
477ed6b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
3 deletions
+52
-3
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+52
-3
No files found.
BTrees/tests/test__base.py
View file @
ea252991
...
@@ -2426,13 +2426,55 @@ class Test_difference(unittest.TestCase, _SetObBase):
...
@@ -2426,13 +2426,55 @@ class Test_difference(unittest.TestCase, _SetObBase):
return
difference
(
*
args
,
**
kw
)
return
difference
(
*
args
,
**
kw
)
def
test_lhs_none
(
self
):
def
test_lhs_none
(
self
):
rhs
=
self
.
_makeSet
(
(
'a'
,
'b'
,
'c'
)
)
rhs
=
self
.
_makeSet
(
'a'
,
'b'
,
'c'
)
self
.
assertEqual
(
self
.
_callFUT
(
rhs
.
__class__
,
None
,
rhs
),
None
)
self
.
assertEqual
(
self
.
_callFUT
(
rhs
.
__class__
,
None
,
rhs
),
None
)
def
test_rhs_none
(
self
):
def
test_rhs_none
(
self
):
lhs
=
self
.
_makeSet
(
(
'a'
,
'b'
,
'c'
)
)
lhs
=
self
.
_makeSet
(
'a'
,
'b'
,
'c'
)
self
.
assertEqual
(
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
None
),
lhs
)
self
.
assertEqual
(
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
None
),
lhs
)
def
test_both_sets_rhs_empty
(
self
):
lhs
=
self
.
_makeSet
(
'a'
,
'b'
,
'c'
)
rhs
=
self
.
_makeSet
()
diff
=
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
rhs
)
self
.
assertEqual
(
list
(
diff
),
list
(
lhs
))
def
test_both_sets_lhs_empty
(
self
):
lhs
=
self
.
_makeSet
()
rhs
=
self
.
_makeSet
(
'a'
,
'b'
,
'c'
)
diff
=
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
rhs
)
self
.
assertEqual
(
list
(
diff
),
list
(
lhs
))
def
test_lhs_set_rhs_mapping
(
self
):
lhs
=
self
.
_makeSet
(
'a'
,
'b'
,
'c'
)
rhs
=
self
.
_makeMapping
({
'a'
:
13
,
'b'
:
12
})
diff
=
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
rhs
)
self
.
assertEqual
(
list
(
diff
),
[
'c'
])
def
test_lhs_mapping_rhs_set
(
self
):
lhs
=
self
.
_makeMapping
({
'a'
:
13
,
'b'
:
12
,
'c'
:
11
})
rhs
=
self
.
_makeSet
(
'a'
,
'b'
)
diff
=
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
rhs
)
self
.
assertEqual
(
list
(
diff
),
[
'c'
])
self
.
assertEqual
(
diff
[
'c'
],
11
)
def
test_both_mappings_rhs_empty
(
self
):
lhs
=
self
.
_makeMapping
({
'a'
:
13
,
'b'
:
12
,
'c'
:
11
})
rhs
=
self
.
_makeMapping
({})
diff
=
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
rhs
)
self
.
assertEqual
(
list
(
diff
),
[
'a'
,
'b'
,
'c'
])
self
.
assertEqual
(
diff
[
'a'
],
13
)
self
.
assertEqual
(
diff
[
'b'
],
12
)
self
.
assertEqual
(
diff
[
'c'
],
11
)
def
test_both_mappings_rhs_non_empty
(
self
):
lhs
=
self
.
_makeMapping
({
'a'
:
13
,
'b'
:
12
,
'c'
:
11
})
rhs
=
self
.
_makeMapping
({
'b'
:
22
})
diff
=
self
.
_callFUT
(
lhs
.
__class__
,
lhs
,
rhs
)
self
.
assertEqual
(
list
(
diff
),
[
'a'
,
'c'
])
self
.
assertEqual
(
diff
[
'a'
],
13
)
self
.
assertEqual
(
diff
[
'c'
],
11
)
class
Test_union
(
unittest
.
TestCase
,
_SetObBase
):
class
Test_union
(
unittest
.
TestCase
,
_SetObBase
):
...
@@ -2492,12 +2534,19 @@ class _Mapping(dict):
...
@@ -2492,12 +2534,19 @@ class _Mapping(dict):
self
.
_values
=
[]
self
.
_values
=
[]
for
k
,
v
in
sorted
(
source
.
items
()):
for
k
,
v
in
sorted
(
source
.
items
()):
self
.
_keys
.
append
(
k
)
self
.
_keys
.
append
(
k
)
self
.
_values
.
append
(
k
)
self
.
_values
.
append
(
v
)
def
MERGE_WEIGHT
(
self
,
v
,
w
):
def
MERGE_WEIGHT
(
self
,
v
,
w
):
return
v
return
v
def
iteritems
(
self
):
def
iteritems
(
self
):
for
k
,
v
in
zip
(
self
.
_keys
,
self
.
_values
):
for
k
,
v
in
zip
(
self
.
_keys
,
self
.
_values
):
yield
k
,
v
yield
k
,
v
def
__iter__
(
self
):
return
iter
(
self
.
_keys
)
def
__getitem__
(
self
,
key
):
search
=
dict
(
zip
(
self
.
_keys
,
self
.
_values
))
return
search
[
key
]
def
__repr__
(
self
):
return
repr
(
dict
(
zip
(
self
.
_keys
,
self
.
_values
)))
_Mapping
.
_set_type
=
_Set
_Mapping
.
_set_type
=
_Set
_Mapping
.
_mapping_type
=
_Mapping
_Mapping
.
_mapping_type
=
_Mapping
...
...
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