aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtCore/duck_punching_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/duck_punching_test.py
parenta2cb6fe0254a122f0ad9d2ee991d9a249903ee12 (diff)
Initia QtCore port to python3.
Diffstat (limited to 'tests/QtCore/duck_punching_test.py')
-rw-r--r--tests/QtCore/duck_punching_test.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/QtCore/duck_punching_test.py b/tests/QtCore/duck_punching_test.py
index e1b9f7fee..8e856ab0d 100644
--- a/tests/QtCore/duck_punching_test.py
+++ b/tests/QtCore/duck_punching_test.py
@@ -4,9 +4,16 @@
import unittest
import types
-from PySide.QtCore import QObject, QEvent
+import sys
+from PySide.QtCore import QObject
from helper import UsesQCoreApplication
+def MethodType(func, instance, instanceType):
+ if sys.version_info[0] == 3:
+ return types.MethodType(func, instance)
+ else:
+ return types.MethodType(func, instance, instanceType)
+
class Duck(QObject):
def __init__(self):
QObject.__init__(self)
@@ -32,7 +39,7 @@ class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication):
parent = QObject()
def childEvent(obj, event):
self.duck_childEvent_called = True
- parent.childEvent = types.MethodType(childEvent, parent, QObject)
+ parent.childEvent = MethodType(childEvent, parent, QObject)
child = QObject()
child.setParent(parent)
self.assert_(self.duck_childEvent_called)
@@ -51,7 +58,7 @@ class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication):
self.duck_childEvent_called = True
child = QObject()
child.setParent(parent)
- parent.childEvent = types.MethodType(childEvent, parent, QObject)
+ parent.childEvent = MethodType(childEvent, parent, QObject)
child = QObject()
child.setParent(parent)
self.assert_(self.duck_childEvent_called)