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
504fa9d0
Commit
504fa9d0
authored
Nov 11, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better test method names.
parent
78a1b0d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
BTrees/tests/test_check.py
BTrees/tests/test_check.py
+15
-16
No files found.
BTrees/tests/test_check.py
View file @
504fa9d0
...
...
@@ -11,12 +11,14 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test the BTree check.check() function."""
import
unittest
class
CheckTest
(
unittest
.
TestCase
):
class
Test_check
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
tree
):
from
BTrees.check
import
check
return
check
(
tree
)
def
_makeOne
(
self
):
from
BTrees.OOBTree
import
OOBTree
...
...
@@ -25,21 +27,19 @@ class CheckTest(unittest.TestCase):
tree
[
i
]
=
2
*
i
return
tree
def
test
N
ormal
(
self
):
def
test
_n
ormal
(
self
):
# Looks like (state, first_bucket)
# where state looks like (bucket0, 15, bucket1).
from
BTrees.check
import
check
tree
=
self
.
_makeOne
()
state
=
tree
.
__getstate__
()
self
.
assertEqual
(
len
(
state
),
2
)
self
.
assertEqual
(
len
(
state
[
0
]),
3
)
self
.
assertEqual
(
state
[
0
][
1
],
15
)
tree
.
_check
()
# shouldn't blow up
check
(
tree
)
# shouldn't blow up
self
.
_callFUT
(
tree
)
# shouldn't blow up
def
test
KeyTooL
arge
(
self
):
def
test
_key_too_l
arge
(
self
):
# Damage an invariant by dropping the BTree key to 14.
from
BTrees.check
import
check
tree
=
self
.
_makeOne
()
state
=
tree
.
__getstate__
()
news
=
(
state
[
0
][
0
],
14
,
state
[
0
][
2
]),
state
[
1
]
...
...
@@ -47,15 +47,14 @@ class CheckTest(unittest.TestCase):
tree
.
_check
()
# not caught
try
:
# Expecting "... key %r >= upper bound %r at index %d"
check
(
tree
)
self
.
_callFUT
(
tree
)
except
AssertionError
as
detail
:
self
.
assertTrue
(
">= upper bound"
in
str
(
detail
))
else
:
self
.
fail
(
"expected check(tree) to catch the problem"
)
def
test
KeyTooS
mall
(
self
):
def
test
_key_too_s
mall
(
self
):
# Damage an invariant by bumping the BTree key to 16.
from
BTrees.check
import
check
tree
=
self
.
_makeOne
()
state
=
tree
.
__getstate__
()
news
=
(
state
[
0
][
0
],
16
,
state
[
0
][
2
]),
state
[
1
]
...
...
@@ -63,15 +62,14 @@ class CheckTest(unittest.TestCase):
tree
.
_check
()
# not caught
try
:
# Expecting "... key %r < lower bound %r at index %d"
check
(
tree
)
self
.
_callFUT
(
tree
)
except
AssertionError
as
detail
:
self
.
assertTrue
(
"< lower bound"
in
str
(
detail
))
else
:
self
.
fail
(
"expected check(tree) to catch the problem"
)
def
test
KeysS
wapped
(
self
):
def
test
_keys_s
wapped
(
self
):
# Damage an invariant by swapping two key/value pairs.
from
BTrees.check
import
check
tree
=
self
.
_makeOne
()
state
=
tree
.
__getstate__
()
# Looks like (state, first_bucket)
...
...
@@ -92,12 +90,13 @@ class CheckTest(unittest.TestCase):
b0
.
__setstate__
((
newpairs
,
nextbucket
))
tree
.
_check
()
# not caught
try
:
check
(
tree
)
self
.
_callFUT
(
tree
)
except
AssertionError
,
detail
:
self
.
assertTrue
(
"key 5 at index 4 >= key 4 at index 5"
in
str
(
detail
))
else
:
self
.
fail
(
"expected check(tree) to catch the problem"
)
def
test_suite
():
return
unittest
.
makeSuite
(
CheckTest
)
return
unittest
.
makeSuite
(
Test_check
)
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