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
cc42ae55
Commit
cc42ae55
authored
Nov 12, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start at tests for conflict resolution.
parent
f686c969
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+55
-0
No files found.
BTrees/tests/test__base.py
View file @
cc42ae55
...
...
@@ -21,6 +21,13 @@ class Test_BucketBase(unittest.TestCase):
from
.._base
import
_BucketBase
return
_BucketBase
def
assertRaises
(
self
,
e_type
,
checked
,
*
args
,
**
kw
):
try
:
checked
(
*
args
,
**
kw
)
except
e_type
as
e
:
return
e
self
.
fail
(
"Didn't raise: %s"
%
e_type
.
__name__
)
def
_makeOne
(
self
,
*
args
,
**
kw
):
return
self
.
_getTargetClass
()(
*
args
,
**
kw
)
...
...
@@ -355,6 +362,54 @@ class Test_BucketBase(unittest.TestCase):
for
key
in
KEYS
:
self
.
assertTrue
(
key
in
bucket
)
def
_with_setstate
(
self
):
class
_WithSetState
(
self
.
_getTargetClass
()):
def
__setstate__
(
self
,
state
):
self
.
_keys
,
self
.
_next
=
state
return
_WithSetState
()
def
test__p_resolveConflict_new_next
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_with_setstate
()
N_NEW
=
object
()
s_old
=
([],
None
)
s_com
=
([],
N_NEW
)
s_new
=
([],
None
)
e
=
self
.
assertRaises
(
BTreesConflictError
,
bucket
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_committed_next
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_with_setstate
()
N_NEW
=
object
()
s_old
=
([],
None
)
s_com
=
([],
None
)
s_new
=
([],
N_NEW
)
e
=
self
.
assertRaises
(
BTreesConflictError
,
bucket
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
0
)
def
test__p_resolveConflict_empty_committed
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_with_setstate
()
s_old
=
([],
None
)
s_com
=
([],
None
)
s_new
=
([
'a'
],
None
)
e
=
self
.
assertRaises
(
BTreesConflictError
,
bucket
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
12
)
def
test__p_resolveConflict_empty_new
(
self
):
from
..Interfaces
import
BTreesConflictError
bucket
=
self
.
_with_setstate
()
s_old
=
([],
None
)
s_com
=
([
'a'
],
None
)
s_new
=
([],
None
)
e
=
self
.
assertRaises
(
BTreesConflictError
,
bucket
.
_p_resolveConflict
,
s_old
,
s_com
,
s_new
)
self
.
assertEqual
(
e
.
reason
,
12
)
def
test_suite
():
return
unittest
.
TestSuite
((
...
...
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