aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtCore/qbytearray_test.py
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-10-03 18:49:42 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:56:08 -0300
commit1e29ab65924166688e352eaaa099ad571a980c4f (patch)
tree2a7ae3cb38b33a3211c9cec0da70016dd5d44c1d /tests/QtCore/qbytearray_test.py
parenta2cb6fe0254a122f0ad9d2ee991d9a249903ee12 (diff)
Initia QtCore port to python3.
Diffstat (limited to 'tests/QtCore/qbytearray_test.py')
-rw-r--r--tests/QtCore/qbytearray_test.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/tests/QtCore/qbytearray_test.py b/tests/QtCore/qbytearray_test.py
index b12f7f9d5..9621a4449 100644
--- a/tests/QtCore/qbytearray_test.py
+++ b/tests/QtCore/qbytearray_test.py
@@ -3,11 +3,10 @@
import unittest
import ctypes
-import sys
import pickle
-import cStringIO
+import py3kcompat as py3k
-from PySide.QtCore import *
+from PySide.QtCore import QByteArray, QSettings, QObject
class QByteArrayTestToNumber(unittest.TestCase):
def testToNumberInt(self):
@@ -30,7 +29,7 @@ class QByteArrayTestToNumber(unittest.TestCase):
def testSetNum(self):
b = QByteArray()
- b.setNum(-124124L)
+ b.setNum(py3k.long(-124124))
self.assertEqual(b, "-124124")
b = QByteArray()
b.setNum(-124124)
@@ -61,13 +60,13 @@ class QByteArrayData(unittest.TestCase):
def testData(self):
url = QByteArray("http://web.openbossa.org/")
- self.assertEqual(url.data(), "http://web.openbossa.org/")
+ self.assertEqual(url.data(), py3k.b("http://web.openbossa.org/"))
def testDataWithZeros(self):
s1 = "123\000321"
ba = QByteArray(s1)
s2 = ba.data()
- self.assertEqual(s1, s2)
+ self.assertEqual(py3k.b(s1), s2)
self.assertEqual(s1, ba)
class QByteArrayOperatorAtSetter(unittest.TestCase):
@@ -127,15 +126,16 @@ class QByteArrayOnQVariant(unittest.TestCase):
class TestBug666(unittest.TestCase):
'''QByteArray does not support slices'''
def testIt(self):
- ba = QByteArray('1234567890')
- self.assertEqual(ba[2:4], '34')
- self.assertEqual(ba[:4], '1234')
- self.assertEqual(ba[4:], '567890')
- self.assertEqual(len(ba[4:1]), 0)
+ if not py3k.IS_PY3K:
+ ba = QByteArray('1234567890')
+ self.assertEqual(ba[2:4], '34')
+ self.assertEqual(ba[:4], '1234')
+ self.assertEqual(ba[4:], '567890')
+ self.assertEqual(len(ba[4:1]), 0)
class QByteArrayBug514(unittest.TestCase):
def testIt(self):
- data = "foobar"
+ data = py3k.b("foobar")
a = QByteArray.fromRawData(data)
self.assertEqual(type(a), QByteArray)
self.assertEqual(a.data(), data)
@@ -143,16 +143,15 @@ class QByteArrayBug514(unittest.TestCase):
class TestPickler(unittest.TestCase):
def testIt(self):
ba = QByteArray("321\x00123")
- output = cStringIO.StringIO()
- pickle.dump(ba, output)
- ba2 = pickle.loads(output.getvalue())
+ output = pickle.dumps(str(ba))
+ ba2 = pickle.loads(output)
self.assertEqual(ba, ba2)
class QByteArrayBug720(unittest.TestCase):
def testIt(self):
- ba = QByteArray("32\"1\x00123")
+ ba = QByteArray(b"32\"1\x00123")
self.assertEqual(str(ba), "32\"1\x00123")
- self.assertEqual(repr(ba), "PySide.QtCore.QByteArray('32\"1\\x00123')")
+ self.assertEqual(repr(ba), "PySide.QtCore.QByteArray('32\"1\x00123')")
class QByteArrayImplicitConvert(unittest.TestCase):
def testString(self):