diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-09-28 17:55:54 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:18:18 -0300 |
commit | b9ab302dd7aff3ecbbbc7ffe1ef2ef0bf4956a5a (patch) | |
tree | b2c62e3ae790b7c5a70f7308282ec2975aa168a2 /tests/samplebinding/bytearray_test.py | |
parent | 6b21c2fa5eeb6a7c7b6533f1c966a47d8ef07e69 (diff) |
Fixed tests to work with python3.x and python2.x
Diffstat (limited to 'tests/samplebinding/bytearray_test.py')
-rw-r--r-- | tests/samplebinding/bytearray_test.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/samplebinding/bytearray_test.py b/tests/samplebinding/bytearray_test.py index 2eb99601f..d2b345989 100644 --- a/tests/samplebinding/bytearray_test.py +++ b/tests/samplebinding/bytearray_test.py @@ -27,6 +27,7 @@ import unittest from os.path import isdir from sample import ByteArray +from py3kcompat import b class ByteArrayBufferProtocolTest(unittest.TestCase): @@ -35,7 +36,7 @@ class ByteArrayBufferProtocolTest(unittest.TestCase): def testByteArrayBufferProtocol(self): # Tests ByteArray implementation of Python buffer protocol using the os.path.isdir # function which an unicode object or other object implementing the Python buffer protocol. - isdir(ByteArray('/tmp')) + isdir(str(ByteArray('/tmp'))) class ByteArrayConcatenationOperatorTest(unittest.TestCase): @@ -90,14 +91,14 @@ class ByteArrayOperatorAt(unittest.TestCase): string = 'abcdefgh' obj = ByteArray(string) for i in range(len(string)): - self.assertEqual(obj[i], string[i]) + self.assertEqual(obj[i], b(string[i])) def testInRangeReverse(self): # ByteArray[x] where x is a valid index (reverse order). string = 'abcdefgh' obj = ByteArray(string) for i in range(len(string)-1, 0, -1): - self.assertEqual(obj[i], string[i]) + self.assertEqual(obj[i], b(string[i])) def testOutOfRange(self): # ByteArray[x] where x is out of index. @@ -107,8 +108,8 @@ class ByteArrayOperatorAt(unittest.TestCase): def testNullStrings(self): ba = ByteArray('\x00') - self.assertEqual(ba.at(0), '\x00') - self.assertEqual(ba[0], '\x00') + self.assertEqual(ba.at(0), b('\x00')) + self.assertEqual(ba[0], b('\x00')) class ByteArrayOperatorLen(unittest.TestCase): @@ -132,7 +133,7 @@ class ByteArrayAndPythonStr(unittest.TestCase): self.assertEqual(ByteArray('aaa').__str__(), 'aaa') def testPythonStrAndNull(self): - s1 = "123\000321" + s1 = b('123\000321') ba = ByteArray(s1) s2 = ba.data() self.assertEqual(s1, s2) |