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
861b1450
Commit
861b1450
authored
Dec 04, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage.
parent
9c2a03e7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
BTrees/_base.py
BTrees/_base.py
+2
-1
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+43
-1
No files found.
BTrees/_base.py
View file @
861b1450
...
@@ -1363,7 +1363,8 @@ def to_float(self, v):
...
@@ -1363,7 +1363,8 @@ def to_float(self, v):
def
to_long
(
self
,
v
):
def
to_long
(
self
,
v
):
try
:
try
:
if
not
unpack
(
"q"
,
pack
(
"q"
,
v
))[
0
]
==
v
:
# XXX Python 2.6 doesn't truncate, it spews a warning.
if
not
unpack
(
"q"
,
pack
(
"q"
,
v
))[
0
]
==
v
:
#pragma NO COVER
if
isinstance
(
v
,
int_types
):
if
isinstance
(
v
,
int_types
):
raise
ValueError
(
"Value out of range"
,
v
)
raise
ValueError
(
"Value out of range"
,
v
)
raise
TypeError
(
'64-bit integer expected'
)
raise
TypeError
(
'64-bit integer expected'
)
...
...
BTrees/tests/test__base.py
View file @
861b1450
...
@@ -2798,7 +2798,7 @@ class Test_multiunion(unittest.TestCase, _SetObBase):
...
@@ -2798,7 +2798,7 @@ class Test_multiunion(unittest.TestCase, _SetObBase):
self
.
assertEqual
(
list
(
result
),
[
1
,
2
])
self
.
assertEqual
(
list
(
result
),
[
1
,
2
])
class
Test_
convert
ers
(
unittest
.
TestCase
):
class
Test_
help
ers
(
unittest
.
TestCase
):
def
test_to_ob
(
self
):
def
test_to_ob
(
self
):
from
BTrees._base
import
to_ob
from
BTrees._base
import
to_ob
...
@@ -2825,6 +2825,11 @@ class Test_converters(unittest.TestCase):
...
@@ -2825,6 +2825,11 @@ class Test_converters(unittest.TestCase):
faux_self
=
object
()
faux_self
=
object
()
self
.
assertRaises
(
TypeError
,
to_int
,
faux_self
,
sys
.
maxint
+
1
)
self
.
assertRaises
(
TypeError
,
to_int
,
faux_self
,
sys
.
maxint
+
1
)
def
test_to_int_w_invalid
(
self
):
from
BTrees._base
import
to_int
faux_self
=
object
()
self
.
assertRaises
(
TypeError
,
to_int
,
faux_self
,
())
def
test_to_float_w_float
(
self
):
def
test_to_float_w_float
(
self
):
from
BTrees._base
import
to_float
from
BTrees._base
import
to_float
faux_self
=
object
()
faux_self
=
object
()
...
@@ -2840,6 +2845,43 @@ class Test_converters(unittest.TestCase):
...
@@ -2840,6 +2845,43 @@ class Test_converters(unittest.TestCase):
faux_self
=
object
()
faux_self
=
object
()
self
.
assertRaises
(
TypeError
,
to_float
,
faux_self
,
())
self
.
assertRaises
(
TypeError
,
to_float
,
faux_self
,
())
def
test_to_long_w_int
(
self
):
from
BTrees._base
import
to_long
faux_self
=
object
()
self
.
assertEqual
(
to_long
(
faux_self
,
3
),
3
)
def
test_to_long_w_long_in_range
(
self
):
from
BTrees._base
import
to_long
faux_self
=
object
()
try
:
self
.
assertEqual
(
to_long
(
faux_self
,
long
(
3
)),
3
)
except
NameError
:
#Python3
pass
def
test_to_long_w_overflow
(
self
):
import
sys
from
BTrees._base
import
to_long
faux_self
=
object
()
self
.
assertRaises
(
ValueError
,
to_long
,
faux_self
,
sys
.
maxint
+
1
)
def
test_to_long_w_invalid
(
self
):
from
BTrees._base
import
to_long
faux_self
=
object
()
self
.
assertRaises
(
TypeError
,
to_long
,
faux_self
,
())
def
test_to_str_w_ok
(
self
):
from
BTrees._base
import
to_str
faux_self
=
object
()
conv
=
to_str
(
3
)
self
.
assertEqual
(
conv
(
faux_self
,
'abc'
),
'abc'
)
def
test_to_str_w_invalid_length
(
self
):
from
BTrees._base
import
to_str
faux_self
=
object
()
conv
=
to_str
(
3
)
self
.
assertRaises
(
TypeError
,
conv
,
faux_self
,
'ab'
)
self
.
assertRaises
(
TypeError
,
conv
,
faux_self
,
'abcd'
)
class
_Cache
(
object
):
class
_Cache
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
...
...
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