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
ccb453f0
Commit
ccb453f0
authored
Nov 11, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
100% coverage for Length.
#Rename test module to match 'test_<MUT>' pattern.
parent
28977e54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
16 deletions
+48
-16
BTrees/Length.py
BTrees/Length.py
+2
-1
BTrees/tests/test_Length.py
BTrees/tests/test_Length.py
+46
-15
No files found.
BTrees/Length.py
View file @
ccb453f0
...
...
@@ -28,8 +28,9 @@ class Length(persistent.Persistent):
longer works as expected, because new-style classes cache
class-defined slot methods (like __len__) in C type slots. Thus,
instance-defined slot fillers are ignored.
"""
# class-level default required to keep copy.deepcopy happy -- see
# https://bugs.launchpad.net/zodb/+bug/516653
value
=
0
def
__init__
(
self
,
v
=
0
):
...
...
BTrees/tests/testLength.py
→
BTrees/tests/test
_
Length.py
View file @
ccb453f0
...
...
@@ -11,40 +11,71 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
\
Test for BTrees.Length module.
"""
__docformat__
=
"reStructuredText"
import
BTrees.Length
import
copy
import
sys
import
unittest
_marker
=
object
()
class
LengthTestCase
(
unittest
.
TestCase
):
def
test_length_overflows_to_long
(
self
):
length
=
BTrees
.
Length
.
Length
(
sys
.
maxint
)
def
_getTargetClass
(
self
):
from
BTrees.Length
import
Length
return
Length
def
_makeOne
(
self
,
value
=
_marker
):
if
value
is
_marker
:
return
self
.
_getTargetClass
()()
return
self
.
_getTargetClass
()(
value
)
def
test_ctor_default
(
self
):
length
=
self
.
_makeOne
()
self
.
assertEqual
(
length
.
value
,
0
)
def
test_ctor_explict
(
self
):
length
=
self
.
_makeOne
(
42
)
self
.
assertEqual
(
length
.
value
,
42
)
def
test___getstate___
(
self
):
length
=
self
.
_makeOne
(
42
)
self
.
assertEqual
(
length
.
__getstate__
(),
42
)
def
test___setstate__
(
self
):
length
=
self
.
_makeOne
()
length
.
__setstate__
(
42
)
self
.
assertEqual
(
length
.
value
,
42
)
def
test_set
(
self
):
length
=
self
.
_makeOne
()
length
.
set
(
42
)
self
.
assertEqual
(
length
.
value
,
42
)
def
test__p_resolveConflict
(
self
):
length
=
self
.
_makeOne
()
self
.
assertEqual
(
length
.
_p_resolveConflict
(
5
,
7
,
9
),
11
)
def
test_change_overflows_to_long
(
self
):
import
sys
length
=
self
.
_makeOne
(
sys
.
maxint
)
self
.
assertEqual
(
length
(),
sys
.
maxint
)
self
.
assert_
(
type
(
length
())
is
int
)
length
.
change
(
+
1
)
self
.
assertEqual
(
length
(),
sys
.
maxint
+
1
)
self
.
assert_
(
type
(
length
())
is
long
)
def
test_length_underflows_to_long
(
self
):
def
test_change_underflows_to_long
(
self
):
import
sys
minint
=
(
-
sys
.
maxint
)
-
1
length
=
BTrees
.
Length
.
Length
(
minint
)
length
=
self
.
_makeOne
(
minint
)
self
.
assertEqual
(
length
(),
minint
)
self
.
assert_
(
type
(
length
())
is
int
)
length
.
change
(
-
1
)
self
.
assertEqual
(
length
(),
minint
-
1
)
self
.
assert_
(
type
(
length
())
is
long
)
def
test_
copy
(
self
):
def
test_
lp_516653
(
self
):
# Test for https://bugs.launchpad.net/zodb/+bug/516653
length
=
BTrees
.
Length
.
Length
()
import
copy
length
=
self
.
_makeOne
()
other
=
copy
.
copy
(
length
)
self
.
assertEqual
(
other
(),
0
)
...
...
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