Commit ef74b918 authored by Tres Seaver's avatar Tres Seaver

Get unicode-driven tests sane under Py3k.

parent 9ec6660f
......@@ -28,30 +28,34 @@ class TestBTreesUnicode(unittest.TestCase):
def setUp(self):
#setup an OOBTree with some unicode strings
from BTrees.OOBTree import OOBTree
from BTrees._compat import _bytes
from BTrees._compat import _u
self.s = unicode('dreit\xe4gigen', 'latin1')
self.s = _u(b'dreit\xe4gigen', 'latin1')
self.data = [('alien', 1),
('k\xf6nnten', 2),
('fox', 3),
('future', 4),
('quick', 5),
('zerst\xf6rt', 6),
(unicode('dreit\xe4gigen','latin1'), 7),
self.data = [(b'alien', 1),
(b'k\xf6nnten', 2),
(b'fox', 3),
(b'future', 4),
(b'quick', 5),
(b'zerst\xf6rt', 6),
(_u(b'dreit\xe4gigen','latin1'), 7),
]
self.tree = OOBTree()
for k, v in self.data:
if isinstance(k, str):
k = unicode(k, 'latin1')
if isinstance(k, _bytes):
k = _u(k, 'latin1')
self.tree[k] = v
@_skip_under_Py3k
def testAllKeys(self):
# check every item of the tree
from BTrees._compat import _u
from BTrees._compat import _bytes
for k, v in self.data:
if isinstance(k, str):
k = unicode(k, encoding)
if isinstance(k, _bytes):
k = _u(k, encoding)
self.assertTrue(k in self.tree)
self.assertEqual(self.tree[k], v)
......@@ -67,7 +71,7 @@ class TestBTreesUnicode(unittest.TestCase):
def testAsciiKeys(self):
# try to access some "plain ASCII" keys in the tree
for k, v in self.data[0], self.data[2]:
self.assert_(isinstance(k, str))
self.assertTrue(isinstance(k, str))
self.assertEqual(self.tree[k], v)
def test_suite():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment