Hi,
I've got a bit of a problem to test my PyQt based code via unit-tests
involving mock objects (specifically minimock).
I'd like to find a way to emit a signal with a mock-object instead of
the real, but I can't seem to find a way to do that. The attached
example demonstrates the problem. Instead of a real Param object I want
to pass in a Mock object
Is there a way to do this?
PyQt 4.8.3, Qt 4.7.3 and sip 4.12.1
Andreas
from PyQt4 import QtCore
from minimock import Mock
class Param(object):
pass
class Source(QtCore.QObject):
mySignal = QtCore.pyqtSignal(Param)
def emitSignal(self, obj):
self.mySignal.emit(obj)
class Target(QtCore.QObject):
def mySlot(self, obj):
print obj
src1 = Source()
target1 = Target()
src1.mySignal.connect(target1.mySlot)
src1.emitSignal(Param())
# This does not help:
Source.mySignal = QtCore.pyqtSignal(Mock)
src2 = Source()
target2 = Target()
src2.mySignal.connect(target1.mySlot)
src2.emitSignal(Mock("Param"))
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt