source | issues

pygtkhelpers.test

Assistance for unittesting pygtk

copyright:2005-2008 by pygtkhelpers Authors
license:LGPL 2 or later (see README/COPYING/LICENSE)
class pygtkhelpers.test.CheckCalled(object, signal)

Utility to check whether a signal has been emitted

Parameters:
  • object – The Object that will fire the signal
  • signal – The signal name

This class should be used when testing whether a signal has been called. It could be used in conjuntion with pygtkhelpers.utils.refresh_gui() in order to block the UI adequately to check:

>>> import gtk
>>> from pygtkhelpers.utils import refresh_gui
>>> b = gtk.Button()
>>> check = CheckCalled(b, 'clicked')
>>> b.clicked()
>>> assert check.called
>>> assert check.called_count = 1
>>> b.click()
>>> assert check.called_count = 2