Initia QtCore port to python3.
This commit is contained in:
parent
a2cb6fe025
commit
1e29ab6592
52 changed files with 380 additions and 286 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue