Updates duck punching test to use 'types' module instead of 'new'.
The 'new' module was deprecated on behalf of 'types' module. Reviewed by Hugo Parente Lima <hugo.lima@openbossa.org>
This commit is contained in:
parent
ca75446b9b
commit
a50ecea26d
1 changed files with 6 additions and 6 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
'''Test case for duck puching new implementations of C++ virtual methods into object instances.'''
|
'''Test case for duck punching new implementations of C++ virtual methods into object instances.'''
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import new
|
import types
|
||||||
from PySide.QtCore import QObject
|
from PySide.QtCore import QObject, QEvent
|
||||||
from helper import UsesQCoreApplication
|
from helper import UsesQCoreApplication
|
||||||
|
|
||||||
class Duck(QObject):
|
class Duck(QObject):
|
||||||
|
|
@ -14,7 +14,7 @@ class Duck(QObject):
|
||||||
QObject.childEvent(self, event)
|
QObject.childEvent(self, event)
|
||||||
|
|
||||||
class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication):
|
class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication):
|
||||||
'''Test case for duck puching new implementations of C++ virtual methods into object instances.'''
|
'''Test case for duck punching new implementations of C++ virtual methods into object instances.'''
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
#Acquire resources
|
#Acquire resources
|
||||||
|
|
@ -33,7 +33,7 @@ class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication):
|
||||||
def childEvent(obj, event):
|
def childEvent(obj, event):
|
||||||
self.duck_childEvent_called = True
|
self.duck_childEvent_called = True
|
||||||
QObject.childEvent(obj, event)
|
QObject.childEvent(obj, event)
|
||||||
parent.event = new.instancemethod(childEvent, parent, QObject)
|
parent.event = types.MethodType(childEvent, parent, QObject)
|
||||||
child = QObject()
|
child = QObject()
|
||||||
child.setParent(parent)
|
child.setParent(parent)
|
||||||
self.assert_(self.duck_childEvent_called)
|
self.assert_(self.duck_childEvent_called)
|
||||||
|
|
@ -46,7 +46,7 @@ class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication):
|
||||||
self.duck_childEvent_called = True
|
self.duck_childEvent_called = True
|
||||||
child = QObject()
|
child = QObject()
|
||||||
child.setParent(parent)
|
child.setParent(parent)
|
||||||
parent.event = new.instancemethod(childEvent, parent, QObject)
|
parent.event = types.MethodType(childEvent, parent, QObject)
|
||||||
child = QObject()
|
child = QObject()
|
||||||
child.setParent(parent)
|
child.setParent(parent)
|
||||||
self.assert_(self.duck_childEvent_called)
|
self.assert_(self.duck_childEvent_called)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue