mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-09-05 17:30:26 +02:00
* Use the new yield * Add some new tests git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69194 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import imp_unittest, unittest
|
|
import wx
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
class WidgetTestCase(unittest.TestCase):
|
|
"""
|
|
A testcase that will create an app and frame for various widget test
|
|
modules to use. They can inherit from this class to save some work. This
|
|
is also good for test cases that just need to have an application object
|
|
created.
|
|
"""
|
|
def setUp(self):
|
|
self.app = wx.App()
|
|
self.frame = wx.Frame(None, title='WTC: '+self.__class__.__name__)
|
|
self.frame.Show()
|
|
|
|
def tearDown(self):
|
|
def _cleanup():
|
|
self.frame.Close()
|
|
self.app.ExitMainLoop()
|
|
wx.CallLater(50, _cleanup)
|
|
self.app.MainLoop()
|
|
del self.app
|
|
|
|
#def tearDown(self):
|
|
# wx.CallAfter(self.frame.Close)
|
|
# self.app.MainLoop()
|
|
# del self.app
|
|
|
|
|
|
# helper methods
|
|
|
|
def myYield(self, eventsToProcess=wx.EVT_CATEGORY_ALL):
|
|
"""
|
|
Since the tests are usually run before MainLoop is called then we
|
|
need to make our own EventLoop for Yield to actually do anything
|
|
useful.
|
|
"""
|
|
evtLoop = self.app.GetTraits().CreateEventLoop()
|
|
activator = wx.EventLoopActivator(evtLoop) # automatically restores the old one
|
|
evtLoop.YieldFor(eventsToProcess)
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|