diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-10-07 15:03:53 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:56:13 -0300 |
commit | 1cefc091180ec4cf44e68e2a776ae1b4bc6d189b (patch) | |
tree | 4d9dc31df2e311577baae67383917835f46c8d44 | |
parent | b841afdb5c09ab431110b34ee463b95d64557731 (diff) |
Fixed unittest to work with python3.
-rw-r--r-- | tests/QtGui/qimage_test.py | 8 | ||||
-rw-r--r-- | tests/util/py3xfunctions.py | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/tests/QtGui/qimage_test.py b/tests/QtGui/qimage_test.py index 8f416b8bb..bf73355cd 100644 --- a/tests/QtGui/qimage_test.py +++ b/tests/QtGui/qimage_test.py @@ -255,8 +255,12 @@ class QImageTest(UsesQApplication): data1 = img0.scanLine(0) data2 = img1.scanLine(0) self.assertEqual(data1, data2) - self.assertEqual(data1, py3k.buffer(img0.bits()[:img0.bytesPerLine()])) - self.assertEqual(data2, py3k.buffer(img0.bits()[:img0.bytesPerLine()])) + + # PySide python 3.x does not support slice yet + if not py3k.IS_PY3K: + buff = py3k.buffer(img0.bits()[:img0.bytesPerLine()]) + self.assertEqual(data1, buff) + self.assertEqual(data2, buff) def testEmptyBuffer(self): img = QImage(py3k.buffer(''), 100, 100, QImage.Format_ARGB32) diff --git a/tests/util/py3xfunctions.py b/tests/util/py3xfunctions.py index 1dd5148df..3b89867a6 100644 --- a/tests/util/py3xfunctions.py +++ b/tests/util/py3xfunctions.py @@ -1,6 +1,14 @@ def b(s): return bytes(s, "UTF8") +def buffer_(s): + if s == None: + return None + elif type(s) == str: + return bytes(s, "UTF8") + else: + memoryview(s) + def l(n): return n @@ -11,4 +19,4 @@ unicode = str unichr = chr long = int unichr = chr -buffer = b +buffer = buffer_ |