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
cf877722
Commit
cf877722
authored
Dec 04, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage.
parent
b5cbd38a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
BTrees/_base.py
BTrees/_base.py
+2
-1
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+32
-0
No files found.
BTrees/_base.py
View file @
cf877722
...
...
@@ -1344,7 +1344,8 @@ def to_ob(self, v):
int_types
=
int
,
long
def
to_int
(
self
,
v
):
try
:
if
not
unpack
(
"i"
,
pack
(
"i"
,
v
))[
0
]
==
v
:
# XXX Python 2.6 doesn't truncate, it spews a warning.
if
not
unpack
(
"i"
,
pack
(
"i"
,
v
))[
0
]
==
v
:
#pragma NO COVER
raise
TypeError
(
'32-bit integer expected'
)
except
(
struct_error
,
OverflowError
,
#PyPy
...
...
BTrees/tests/test__base.py
View file @
cf877722
...
...
@@ -2699,6 +2699,8 @@ class Test_weightedUnion(unittest.TestCase, _SetObBase):
self
.
assertEqual
(
weight
,
1
)
self
.
assertEqual
(
list
(
result
),
[
1
,
2
,
3
,
4
])
#TODO: test non-default weights
class
Test_weightedIntersection
(
unittest
.
TestCase
,
_SetObBase
):
...
...
@@ -2770,6 +2772,8 @@ class Test_weightedIntersection(unittest.TestCase, _SetObBase):
self
.
assertEqual
(
weight
,
2
)
self
.
assertEqual
(
list
(
result
),
[
1
])
#TODO: test non-default weights
class
Test_multiunion
(
unittest
.
TestCase
,
_SetObBase
):
...
...
@@ -2794,6 +2798,34 @@ class Test_multiunion(unittest.TestCase, _SetObBase):
self
.
assertEqual
(
list
(
result
),
[
1
,
2
])
class
Test_converters
(
unittest
.
TestCase
):
def
test_to_ob
(
self
):
from
BTrees._base
import
to_ob
faux_self
=
object
()
for
thing
in
"abc"
,
0
,
1.3
,
(),
frozenset
((
1
,
2
)),
object
():
self
.
assertTrue
(
to_ob
(
faux_self
,
thing
)
is
thing
)
def
test_to_int_w_int
(
self
):
from
BTrees._base
import
to_int
faux_self
=
object
()
self
.
assertEqual
(
to_int
(
faux_self
,
3
),
3
)
def
test_to_int_w_long_in_range
(
self
):
from
BTrees._base
import
to_int
faux_self
=
object
()
try
:
self
.
assertEqual
(
to_int
(
faux_self
,
long
(
3
)),
3
)
except
NameError
:
#Python3
pass
def
test_to_int_w_overflow
(
self
):
import
sys
from
BTrees._base
import
to_int
faux_self
=
object
()
self
.
assertRaises
(
TypeError
,
to_int
,
faux_self
,
sys
.
maxint
+
1
)
class
_Cache
(
object
):
def
__init__
(
self
):
self
.
_mru
=
[]
...
...
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