From 3783278a2bcd753f2f124f6932a5eccd726b422c Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 4 Jul 2016 14:56:54 -0700 Subject: [PATCH] Try harder AND smarter to avoid stuck tests, where tests seem to run fine but don't terminate correctly. --- unittests/wtc.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/unittests/wtc.py b/unittests/wtc.py index d6873af3..a640a418 100644 --- a/unittests/wtc.py +++ b/unittests/wtc.py @@ -16,16 +16,21 @@ class WidgetTestCase(unittest.TestCase): self.app = wx.App() wx.Log.SetActiveTarget(wx.LogStderr()) self.frame = wx.Frame(None, title='WTC: '+self.__class__.__name__) - self.frame.Show() def tearDown(self): def _cleanup(): for tlw in wx.GetTopLevelWindows(): if tlw: - tlw.Destroy() + if isinstance(tlw, wx.Dialog) and tlw.IsModal(): + tlw.EndModal(0) + wx.CallAfter(tlw.Destroy) + else: + tlw.Close(force=True) wx.WakeUpIdle() - #self.app.ExitMainLoop() - wx.CallLater(50, _cleanup) + + timer = wx.PyTimer(_cleanup) + timer.Start(100) + self.frame.Show() self.app.MainLoop() del self.app