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
31df1ba5
Commit
31df1ba5
authored
Oct 18, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further test cleanups.
Don't need ZODB / functest to test string comparison stuff.
parent
8b92cfe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
41 deletions
+31
-41
BTrees/tests/test_compare.py
BTrees/tests/test_compare.py
+31
-41
No files found.
BTrees/tests/test_compare.py
View file @
31df1ba5
...
@@ -15,71 +15,61 @@
...
@@ -15,71 +15,61 @@
import
unittest
import
unittest
from
BTrees.OOBTree
import
OOBucket
as
Bucket
,
OOSet
as
Set
import
transaction
STR
=
"A string with hi-bit-set characters:
\
700
\
701
"
from
ZODB.MappingStorage
import
MappingStorage
UNICODE
=
u"A unicode string"
from
ZODB.DB
import
DB
class
CompareTest
(
unittest
.
TestCase
):
s
=
"A string with hi-bit-set characters:
\
700
\
701
"
class
CompareTest
(
unittest
.
TestCase
):
u
=
u"A unicode string"
def
setUp
(
self
):
def
setUp
(
self
):
# These defaults only make sense if the default encoding
# These defaults only make sense if the default encoding
# prevents
s
from being promoted to Unicode.
# prevents
STR
from being promoted to Unicode.
self
.
assertRaises
(
UnicodeError
,
unicode
,
self
.
s
)
self
.
assertRaises
(
UnicodeError
,
unicode
,
STR
)
# An object needs to be added to the database to
def
_makeBucket
(
self
):
self
.
db
=
DB
(
MappingStorage
())
from
BTrees.OOBTree
import
OOBucket
root
=
self
.
db
.
open
().
root
()
return
OOBucket
()
self
.
bucket
=
root
[
"bucket"
]
=
Bucket
()
self
.
set
=
root
[
"set"
]
=
Set
()
transaction
.
commit
()
def
tearDown
(
self
):
def
_makeSet
(
self
):
self
.
assert_
(
self
.
bucket
.
_p_changed
!=
2
)
from
BTrees.OOBTree
import
OOSet
self
.
assert_
(
self
.
set
.
_p_changed
!=
2
)
return
OOSet
()
transaction
.
abort
()
def
assertUE
(
self
,
callable
,
*
args
):
def
assertUE
(
self
,
callable
,
*
args
):
self
.
assertRaises
(
UnicodeError
,
callable
,
*
args
)
self
.
assertRaises
(
UnicodeError
,
callable
,
*
args
)
def
testBucketGet
(
self
):
def
testBucketGet
(
self
):
import
sys
import
warnings
import
warnings
_warnlog
=
[]
b
=
self
.
_makeBucket
()
def
_showwarning
(
*
args
,
**
kw
):
with
warnings
.
catch_warnings
(
True
)
as
_warnlog
:
_warnlog
.
append
((
args
,
kw
))
b
[
STR
]
=
1
warnings
.
showwarning
,
_before
=
_showwarning
,
warnings
.
showwarning
self
.
assertUE
(
b
.
get
,
UNICODE
)
try
:
self
.
assertEqual
(
len
(
_warnlog
),
1
)
self
.
bucket
[
self
.
s
]
=
1
self
.
assertUE
(
self
.
bucket
.
get
,
self
.
u
)
finally
:
warnings
.
showwarning
=
_before
if
sys
.
version_info
>=
(
2
,
6
):
self
.
assertEqual
(
len
(
_warnlog
),
1
)
def
testSetGet
(
self
):
def
testSetGet
(
self
):
self
.
set
.
insert
(
self
.
s
)
s
=
self
.
_makeSet
()
self
.
assertUE
(
self
.
set
.
remove
,
self
.
u
)
s
.
insert
(
STR
)
self
.
assertUE
(
s
.
remove
,
UNICODE
)
def
testBucketSet
(
self
):
def
testBucketSet
(
self
):
self
.
bucket
[
self
.
s
]
=
1
b
=
self
.
_makeBucket
()
self
.
assertUE
(
self
.
bucket
.
__setitem__
,
self
.
u
,
1
)
b
[
STR
]
=
1
self
.
assertUE
(
b
.
__setitem__
,
UNICODE
,
1
)
def
testSetSet
(
self
):
def
testSetSet
(
self
):
self
.
set
.
insert
(
self
.
s
)
s
=
self
.
_makeSet
()
self
.
assertUE
(
self
.
set
.
insert
,
self
.
u
)
s
.
insert
(
STR
)
self
.
assertUE
(
s
.
insert
,
UNICODE
)
def
testBucketMinKey
(
self
):
def
testBucketMinKey
(
self
):
self
.
bucket
[
self
.
s
]
=
1
b
=
self
.
_makeBucket
()
self
.
assertUE
(
self
.
bucket
.
minKey
,
self
.
u
)
b
[
STR
]
=
1
self
.
assertUE
(
b
.
minKey
,
UNICODE
)
def
testSetMinKey
(
self
):
def
testSetMinKey
(
self
):
self
.
set
.
insert
(
self
.
s
)
s
=
self
.
_makeSet
()
self
.
assertUE
(
self
.
set
.
minKey
,
self
.
u
)
s
.
insert
(
STR
)
self
.
assertUE
(
s
.
minKey
,
UNICODE
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
CompareTest
)
return
unittest
.
makeSuite
(
CompareTest
)
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