summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-10-06 11:38:31 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-10-06 15:43:32 -0300
commit0647ae2b88f08ac9a1894afe8a756965ad4133bf (patch)
tree18b4c4f1d0011908624cb5c32a78731917500154
parente2eaf4f44b207a73d5f9bf67b5310584441e7ecf (diff)
downloadpyside-0647ae2b88f08ac9a1894afe8a756965ad4133bf.tar.gz
pyside-0647ae2b88f08ac9a1894afe8a756965ad4133bf.tar.xz
pyside-0647ae2b88f08ac9a1894afe8a756965ad4133bf.zip
Updated QtGui modue to works with python 2.x and 3.x
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml8
-rw-r--r--tests/QtGui/api2_test.py5
-rw-r--r--tests/QtGui/bug_493.py5
-rw-r--r--tests/QtGui/bug_569.py4
-rw-r--r--tests/QtGui/bug_660.py8
-rw-r--r--tests/QtGui/bug_740.py6
-rw-r--r--tests/QtGui/pyside_reload_test.py32
-rw-r--r--tests/QtGui/qabstracttextdocumentlayout_test.py8
-rw-r--r--tests/QtGui/qfontmetrics_test.py32
-rw-r--r--tests/QtGui/qgraphicsscene_test.py23
-rw-r--r--tests/QtGui/qimage_test.py9
-rw-r--r--tests/QtGui/qpixmapcache_test.py3
-rw-r--r--tests/QtGui/qstring_qkeysequence_test.py4
-rw-r--r--tests/QtGui/test_module_template.py7
-rw-r--r--tests/QtGui/wrong_return_test.py11
15 files changed, 94 insertions, 71 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 5067812..7fbfb7e 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -1462,7 +1462,7 @@
<modify-function signature="boundingRect(QChar)const" rename="boundingRectChar">
<modify-argument index="1">
- <replace-type modified-type="PyBytes"/>
+ <replace-type modified-type="char"/>
</modify-argument>
<inject-code class="target" position="beginning">
<insert-template name="QFontCharFix"/>
@@ -1471,7 +1471,7 @@
<modify-function signature="width(QChar)const" rename="widthChar">
<modify-argument index="1">
- <replace-type modified-type="PyBytes"/>
+ <replace-type modified-type="char"/>
</modify-argument>
<inject-code class="target" position="beginning">
<insert-template name="QFontCharFix"/>
@@ -1538,7 +1538,7 @@
<modify-function signature="boundingRect(QChar)const" rename="boundingRectChar">
<modify-argument index="1">
- <replace-type modified-type="PyBytes"/>
+ <replace-type modified-type="char"/>
</modify-argument>
<inject-code class="target" position="beginning">
<insert-template name="QFontCharFix"/>
@@ -1547,7 +1547,7 @@
<modify-function signature="width(QChar)const" rename="widthChar">
<modify-argument index="1">
- <replace-type modified-type="PyBytes"/>
+ <replace-type modified-type="char"/>
</modify-argument>
<inject-code class="target" position="beginning">
<insert-template name="QFontCharFix"/>
diff --git a/tests/QtGui/api2_test.py b/tests/QtGui/api2_test.py
index 42edba0..f7295ea 100644
--- a/tests/QtGui/api2_test.py
+++ b/tests/QtGui/api2_test.py
@@ -4,8 +4,7 @@
import unittest
import sys
-from PySide.QtCore import QObject
-from PySide.QtGui import *
+from PySide.QtGui import QWidget, QIntValidator, QSpinBox, QValidator, QApplication
from helper import UsesQApplication
@@ -19,7 +18,7 @@ class WidgetValidatorQSpinBox(QSpinBox):
QSpinBox.__init__(self, parent)
def fixup(self, text):
- print "It was called!"
+ print("It was called!")
class DoubleQObjectInheritanceTest(UsesQApplication):
diff --git a/tests/QtGui/bug_493.py b/tests/QtGui/bug_493.py
index bf19fa7..ba68175 100644
--- a/tests/QtGui/bug_493.py
+++ b/tests/QtGui/bug_493.py
@@ -1,5 +1,5 @@
-from PySide.QtCore import *
-from PySide.QtGui import *
+from PySide.QtCore import Qt, QEvent
+from PySide.QtGui import QApplication, QKeyEvent, QKeySequence
import unittest
@@ -12,6 +12,7 @@ class TestBug569(unittest.TestCase):
ev1 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Delete, Qt.NoModifier)
ev2 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Copy, Qt.NoModifier)
ks = QKeySequence.Delete
+
self.assertEqual(ev1, ks)
self.assertEqual(ks, ev1)
self.assertNotEqual(ev2, ks)
diff --git a/tests/QtGui/bug_569.py b/tests/QtGui/bug_569.py
index 00d92ed..c31a4ca 100644
--- a/tests/QtGui/bug_569.py
+++ b/tests/QtGui/bug_569.py
@@ -9,9 +9,9 @@ class TestBug569(unittest.TestCase):
types = (QTableWidgetItem, QListWidgetItem, QTreeWidgetItem)
for t in types:
a = t()
- a.__lt__ = lambda(other) : True
+ a.__lt__ = lambda other : True
b = t()
- b.__lt__ = lambda(other) : False
+ b.__lt__ = lambda other : False
self.assertTrue(a < b)
self.assertFalse(b < a)
diff --git a/tests/QtGui/bug_660.py b/tests/QtGui/bug_660.py
index f001d36..b97217f 100644
--- a/tests/QtGui/bug_660.py
+++ b/tests/QtGui/bug_660.py
@@ -1,6 +1,6 @@
import unittest
-from PySide.QtCore import *
-from PySide.QtGui import *
+import py3kcompat as py3k
+from PySide.QtGui import QStandardItemModel, QStandardItem
class MyItemModel(QStandardItemModel):
def __init__(self,parent=None):
@@ -9,12 +9,12 @@ class MyItemModel(QStandardItemModel):
def mimeTypes(self):
mtypes = super(MyItemModel,self).mimeTypes()
- mtypes.append(u'application/my-form')
+ mtypes.append(py3k.unicode_('application/my-form'))
return mtypes
def mimeData(self,indexes):
self.__mimedata = super(MyItemModel,self).mimeData(indexes)
- self.__mimedata.setData(u'application/my-form', 'hi')
+ self.__mimedata.setData(py3k.unicode_('application/my-form'), 'hi')
return self.__mimedata
class TestBug660(unittest.TestCase):
diff --git a/tests/QtGui/bug_740.py b/tests/QtGui/bug_740.py
index 634a99e..302a1a1 100644
--- a/tests/QtGui/bug_740.py
+++ b/tests/QtGui/bug_740.py
@@ -1,12 +1,12 @@
import unittest
-
+import py3kcompat as py3k
from helper import UsesQApplication
from PySide.QtCore import QSize
-from PySide.QtGui import QBitmap, QImage, QLabel
+from PySide.QtGui import QBitmap, QImage
class TestQBitmap(UsesQApplication):
def testFromDataMethod(self):
- dataBits = '\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10'
+ dataBits = py3k.b('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10')
bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function
if __name__ == '__main__':
diff --git a/tests/QtGui/pyside_reload_test.py b/tests/QtGui/pyside_reload_test.py
index ca12b8b..3fd593c 100644
--- a/tests/QtGui/pyside_reload_test.py
+++ b/tests/QtGui/pyside_reload_test.py
@@ -2,6 +2,7 @@ import os
import sys
import shutil
import unittest
+import py3kcompat as py3k
orig_path = os.path.join(os.path.dirname(__file__))
workdir = os.getcwd()
@@ -10,12 +11,25 @@ dst = os.path.join(workdir, 'test_module.py')
shutil.copyfile(src, dst)
sys.path.append(workdir)
+def reload_module(moduleName):
+ if py3k.IS_PY3K:
+ import imp
+ imp.reload(moduleName)
+ else:
+ reload(moduleName)
+
def increment_module_value():
modfile = open(dst, 'a')
- modfile.write('MyQWidget.value += 1' + os.linesep)
+ modfile.write('Sentinel.value += 1' + os.linesep)
modfile.flush()
modfile.close()
- os.remove(dst + 'c')
+ if py3k.IS_PY3K:
+ import imp
+ cacheFile = imp.cache_from_source(dst)
+ else:
+ cacheFile = dst + 'c'
+
+ os.remove(cacheFile)
class TestModuleReloading(unittest.TestCase):
@@ -23,18 +37,18 @@ class TestModuleReloading(unittest.TestCase):
'''Test module reloading with on-the-fly modifications.'''
import test_module
- self.assertEqual(test_module.MyQWidget.value, 10)
+ self.assertEqual(test_module.Sentinel.value, 10)
increment_module_value()
- reload(sys.modules['test_module'])
- self.assertEqual(test_module.MyQWidget.value, 11)
+ reload_module(sys.modules['test_module'])
+ self.assertEqual(test_module.Sentinel.value, 11)
- reload(sys.modules['test_module'])
- self.assertEqual(test_module.MyQWidget.value, 11)
+ reload_module(sys.modules['test_module'])
+ self.assertEqual(test_module.Sentinel.value, 11)
increment_module_value()
- reload(sys.modules['test_module'])
- self.assertEqual(test_module.MyQWidget.value, 12)
+ reload_module(sys.modules['test_module'])
+ self.assertEqual(test_module.Sentinel.value, 12)
if __name__ == "__main__":
unittest.main()
diff --git a/tests/QtGui/qabstracttextdocumentlayout_test.py b/tests/QtGui/qabstracttextdocumentlayout_test.py
index e3fe40e..8a8a0c7 100644
--- a/tests/QtGui/qabstracttextdocumentlayout_test.py
+++ b/tests/QtGui/qabstracttextdocumentlayout_test.py
@@ -1,8 +1,8 @@
import unittest
-import colorsys
+import py3kcompat as py3k
-from PySide.QtCore import *
-from PySide.QtGui import *
+from PySide.QtCore import QSizeF, QTimer
+from PySide.QtGui import QTextFormat, QTextCharFormat, QTextEdit, QPyTextObject
from helper import UsesQApplication
class Foo(QPyTextObject):
@@ -24,7 +24,7 @@ class QAbstractTextDocumentLayoutTest(UsesQApplication):
fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType)
cursor = self.textEdit.textCursor()
- cursor.insertText(unichr(0xfffc), fmt)
+ cursor.insertText(py3k.unichr(0xfffc), fmt)
self.textEdit.setTextCursor(cursor)
self.textEdit.close()
diff --git a/tests/QtGui/qfontmetrics_test.py b/tests/QtGui/qfontmetrics_test.py
index 96c022f..59f01f9 100644
--- a/tests/QtGui/qfontmetrics_test.py
+++ b/tests/QtGui/qfontmetrics_test.py
@@ -30,21 +30,21 @@ class BoundingRectTest(QFontMetricsTest):
rect = self.metrics.boundingRect(0, 0, 0, 0,
Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT')
- self.assert_(isinstance(rect, QRect))
+ self.assertTrue(isinstance(rect, QRect))
def testIntWithArg(self):
'''QFontMetrics.boundingRect(int, int, int, int, ...) - single arg'''
rect = self.metrics.boundingRect(0, 0, 0, 0,
Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT', 2)
- self.assert_(isinstance(rect, QRect))
+ self.assertTrue(isinstance(rect, QRect))
def testIntWithFull(self):
'''QFontMetrics.boundingRect(int, int, int, int, ...) - all argss'''
rect = self.metrics.boundingRect(0, 0, 0, 0,
Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT', 20, [1, 2, 3, 4, 5])
- self.assert_(isinstance(rect, QRect))
+ self.assertTrue(isinstance(rect, QRect))
def testIntTypeError(self):
'''QFontMetrics.boundingRect(int, int, int, int, ...) - type error'''
@@ -57,14 +57,14 @@ class BoundingRectTest(QFontMetricsTest):
arg = QRect(0, 0, 100, 200)
rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT')
- self.assert_(isinstance(rect, QRect))
+ self.assertTrue(isinstance(rect, QRect))
def testQRectWithArg(self):
'''QFontMetrics.boundingRect(QRect, ...) - only tabstops'''
arg = QRect(0, 0, 100, 200)
rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT', 2)
- self.assert_(isinstance(rect, QRect))
+ self.assertTrue(isinstance(rect, QRect))
def testQRectWithFull(self):
'''QFontMetrics.boundingRect(QRect, ...) - all arguments'''
@@ -72,7 +72,7 @@ class BoundingRectTest(QFontMetricsTest):
rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT', 20,
[1, 2, 3, 4, 5])
- self.assert_(isinstance(rect, QRect))
+ self.assertTrue(isinstance(rect, QRect))
def testQRectTypeError(self):
'''QFontMetrics.boundingRect(QRect, ...) - type error'''
@@ -89,19 +89,19 @@ class SizeTest(QFontMetricsTest):
'''QFontMetrics.size - default arguments'''
size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
'PySide by INdT')
- self.assert_(isinstance(size, QSize))
+ self.assertTrue(isinstance(size, QSize))
def testWithTabStops(self):
'''QFontMetrics.size - only tabstops'''
size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
'PySide by INdT', 2)
- self.assert_(isinstance(size, QSize))
+ self.assertTrue(isinstance(size, QSize))
def testFull(self):
'''QFontMetrics.size - all arguments'''
size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
'PySide by INdT', 2, [1, 2, 3, 4])
- self.assert_(isinstance(size, QSize))
+ self.assertTrue(isinstance(size, QSize))
def testTypeError(self):
'''QFontMetrics.size - type error'''
@@ -132,14 +132,14 @@ class FBoundingRectTest(QFontMetricsFTest):
arg = QRectF(0, 0, 100, 200)
rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT')
- self.assert_(isinstance(rect, QRectF))
+ self.assertTrue(isinstance(rect, QRectF))
def testQRectWithArg(self):
'''QFontMetricsF.boundingRect(QRectF, ...) - only tabstops'''
arg = QRectF(0, 0, 100, 200)
rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT', 2)
- self.assert_(isinstance(rect, QRectF))
+ self.assertTrue(isinstance(rect, QRectF))
def testQRectWithFull(self):
'''QFontMetricsF.boundingRect(QRectF, ...) - all arguments'''
@@ -147,7 +147,7 @@ class FBoundingRectTest(QFontMetricsFTest):
rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
'PySide by INdT', 20,
[1, 2, 3, 4, 5])
- self.assert_(isinstance(rect, QRectF))
+ self.assertTrue(isinstance(rect, QRectF))
def testQRectTypeError(self):
'''QFontMetricsF.boundingRect(QRectF, ...) - type error'''
@@ -164,19 +164,19 @@ class FSizeTest(QFontMetricsFTest):
'''QFontMetricsF.size - default arguments'''
size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
'PySide by INdT')
- self.assert_(isinstance(size, QSizeF))
+ self.assertTrue(isinstance(size, QSizeF))
def testWithTabStops(self):
'''QFontMetricsF.size - only tabstops'''
size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
'PySide by INdT', 2)
- self.assert_(isinstance(size, QSizeF))
+ self.assertTrue(isinstance(size, QSizeF))
def testFull(self):
'''QFontMetricsF.size - all arguments'''
size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
'PySide by INdT', 2, [1, 2, 3, 4])
- self.assert_(isinstance(size, QSizeF))
+ self.assertTrue(isinstance(size, QSizeF))
def testTypeError(self):
'''QFontMetricsF.size - type error'''
@@ -193,7 +193,7 @@ class QCharTest(QFontMetricsFTest):
def testWith(self):
retCh = self.metrics.widthChar('a')
- self.assert_(retCh > 0)
+ self.assertTrue(retCh > 0)
if __name__ == '__main__':
unittest.main()
diff --git a/tests/QtGui/qgraphicsscene_test.py b/tests/QtGui/qgraphicsscene_test.py
index 85f5004..b8fffc6 100644
--- a/tests/QtGui/qgraphicsscene_test.py
+++ b/tests/QtGui/qgraphicsscene_test.py
@@ -21,7 +21,7 @@ class Constructor(unittest.TestCase):
def testConstructor(self):
#QGraphicsScene constructor
obj = QGraphicsScene()
- self.assert_(isinstance(obj, QGraphicsScene))
+ self.assertTrue(isinstance(obj, QGraphicsScene))
class ConstructorWithRect(unittest.TestCase):
@@ -65,49 +65,49 @@ class AddItem(UsesQApplication):
def testEllipse(self):
#QGraphicsScene.addEllipse
item = self.scene.addEllipse(100, 100, 100, 100)
- self.assert_(isinstance(item, QGraphicsEllipseItem))
+ self.assertTrue(isinstance(item, QGraphicsEllipseItem))
def testLine(self):
#QGraphicsScene.addLine
item = self.scene.addLine(100, 100, 200, 200)
- self.assert_(isinstance(item, QGraphicsLineItem))
+ self.assertTrue(isinstance(item, QGraphicsLineItem))
def testPath(self):
#QGraphicsScene.addPath
item = self.scene.addPath(QPainterPath())
- self.assert_(isinstance(item, QGraphicsPathItem))
+ self.assertTrue(isinstance(item, QGraphicsPathItem))
def testPixmap(self):
#QGraphicsScene.addPixmap
item = self.scene.addPixmap(QPixmap())
- self.assert_(isinstance(item, QGraphicsPixmapItem))
+ self.assertTrue(isinstance(item, QGraphicsPixmapItem))
def testPolygon(self):
#QGraphicsScene.addPolygon
points = [QPointF(0, 0), QPointF(100, 100), QPointF(0, 100)]
item = self.scene.addPolygon(QPolygonF(points))
- self.assert_(isinstance(item, QGraphicsPolygonItem))
+ self.assertTrue(isinstance(item, QGraphicsPolygonItem))
def testRect(self):
#QGraphicsScene.addRect
item = self.scene.addRect(100, 100, 100, 100)
- self.assert_(isinstance(item, QGraphicsRectItem))
+ self.assertTrue(isinstance(item, QGraphicsRectItem))
def testSimpleText(self):
#QGraphicsScene.addSimpleText
item = self.scene.addSimpleText('Monty Python 42')
- self.assert_(isinstance(item, QGraphicsSimpleTextItem))
+ self.assertTrue(isinstance(item, QGraphicsSimpleTextItem))
def testText(self):
#QGraphicsScene.addText
item = self.scene.addText('Monty Python 42')
- self.assert_(isinstance(item, QGraphicsTextItem))
+ self.assertTrue(isinstance(item, QGraphicsTextItem))
def testWidget(self):
#QGraphicsScene.addWidget
# XXX: printing some X11 error when using under PyQt4
item = self.scene.addWidget(QPushButton())
- self.assert_(isinstance(item, QGraphicsProxyWidget))
+ self.assertTrue(isinstance(item, QGraphicsProxyWidget))
class ItemRetrieve(UsesQApplication):
@@ -139,7 +139,8 @@ class ItemRetrieve(UsesQApplication):
def testItems(self):
#QGraphicsScene.items()
items = self.scene.items()
- self.assertEqual(items.sort(), self.items.sort())
+ for i in items:
+ self.assertTrue(i in self.items)
def testItemAt(self):
#QGraphicsScene.itemAt()
diff --git a/tests/QtGui/qimage_test.py b/tests/QtGui/qimage_test.py
index 2eb55ac..8f416b8 100644
--- a/tests/QtGui/qimage_test.py
+++ b/tests/QtGui/qimage_test.py
@@ -2,6 +2,7 @@
'''Test cases for QImage'''
import unittest
+import py3kcompat as py3k
from PySide.QtGui import *
from helper import UsesQApplication, adjust_filename
@@ -254,14 +255,14 @@ class QImageTest(UsesQApplication):
data1 = img0.scanLine(0)
data2 = img1.scanLine(0)
self.assertEqual(data1, data2)
- self.assertEquals(str(data1), img0.bits()[:img0.bytesPerLine()])
- self.assertEquals(str(data2), img0.bits()[:img0.bytesPerLine()])
+ self.assertEqual(data1, py3k.buffer(img0.bits()[:img0.bytesPerLine()]))
+ self.assertEqual(data2, py3k.buffer(img0.bits()[:img0.bytesPerLine()]))
def testEmptyBuffer(self):
- img = QImage(buffer(''), 100, 100, QImage.Format_ARGB32)
+ img = QImage(py3k.buffer(''), 100, 100, QImage.Format_ARGB32)
def testEmptyStringAsBuffer(self):
- img = QImage('', 100, 100, QImage.Format_ARGB32)
+ img = QImage(py3k.b(''), 100, 100, QImage.Format_ARGB32)
def testXpmConstructor(self):
label = QLabel()
diff --git a/tests/QtGui/qpixmapcache_test.py b/tests/QtGui/qpixmapcache_test.py
index 68b4d92..7795b5d 100644
--- a/tests/QtGui/qpixmapcache_test.py
+++ b/tests/QtGui/qpixmapcache_test.py
@@ -19,7 +19,8 @@ class QPixmapCacheTest(UsesQApplication):
pm3 = QPixmap()
ok = QPixmapCache.find('img', pm3)
self.assertTrue(ok)
-
+ b1 = QPixmapCache.find('img').toImage().bits()
+ b2 = pm3.toImage().bits()
self.assertEqual(QPixmapCache.find('img').toImage().bits(), pm3.toImage().bits())
def testWithKey(self):
diff --git a/tests/QtGui/qstring_qkeysequence_test.py b/tests/QtGui/qstring_qkeysequence_test.py
index 15db935..e8e307d 100644
--- a/tests/QtGui/qstring_qkeysequence_test.py
+++ b/tests/QtGui/qstring_qkeysequence_test.py
@@ -3,9 +3,9 @@
'''Tests conversions of QString to and from QKeySequence.'''
import unittest
+import py3kcompat as py3k
from helper import UsesQApplication
-from PySide.QtCore import *
from PySide.QtGui import QKeySequence, QAction
class QStringQKeySequenceTest(UsesQApplication):
@@ -19,7 +19,7 @@ class QStringQKeySequenceTest(UsesQApplication):
def testPythonStringAsQKeySequence(self):
'''Passes a Python string to an argument expecting a QKeySequence.'''
- keyseq = u'Ctrl+A'
+ keyseq = py3k.unicode_('Ctrl+A')
action = QAction(None)
action.setShortcut(keyseq)
shortcut = action.shortcut()
diff --git a/tests/QtGui/test_module_template.py b/tests/QtGui/test_module_template.py
index fb72a97..f1e3010 100644
--- a/tests/QtGui/test_module_template.py
+++ b/tests/QtGui/test_module_template.py
@@ -1,9 +1,12 @@
-from PySide.QtGui import *
-from PySide.QtCore import *
+from PySide.QtGui import QWidget
+from PySide.QtCore import QObject
class MyQObject(QObject):
pass
class MyQWidget(QWidget):
+ pass
+
+class Sentinel():
value = 10
diff --git a/tests/QtGui/wrong_return_test.py b/tests/QtGui/wrong_return_test.py
index 1807e4a..8394f6e 100644
--- a/tests/QtGui/wrong_return_test.py
+++ b/tests/QtGui/wrong_return_test.py
@@ -1,9 +1,8 @@
'''Test cases for Virtual functions with wrong return type'''
import unittest
-
-from PySide import QtCore, QtGui
-
+import py3kcompat as py3k
+from PySide import QtGui
from helper import UsesQApplication
import warnings
@@ -21,7 +20,11 @@ class testCase(UsesQApplication):
def testVirtualReturn(self):
w = MyWidget()
- self.assertRaises(RuntimeWarning, w.show)
+ if py3k.IS_PY3K:
+ self.assertWarns(RuntimeWarning, w.show)
+ else:
+ self.assertRaises(RuntimeWarning, w.show)
+
if __name__ == '__main__':
unittest.main()