From de9edce1b125dec227802758e39523f13d866117 Mon Sep 17 00:00:00 2001 From: James Wettenhall Date: Thu, 23 Mar 2017 22:02:13 +1100 Subject: [PATCH] Wait 300 milliseconds before tearDown to give the FlickerTLW's wx.CallLater a chance to run, which avoids this exception: wx/core.py, line 3096, in Notify self.result = self.callable(*self.args, **self.kwargs) RuntimeError: wrapped C/C++ object of type Filling has been deleted Ensure that the Crust object's "lastsashpos" attribute is defined to avoid this exception: wx/py/crust.py", line 150, in SaveSettings if self.lastsashpos != -1: AttributeError: 'Crust' object has no attribute 'lastsashpos' --- unittests/test_lib_mixins_inspection.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/unittests/test_lib_mixins_inspection.py b/unittests/test_lib_mixins_inspection.py index fea951e5..39f62ba5 100644 --- a/unittests/test_lib_mixins_inspection.py +++ b/unittests/test_lib_mixins_inspection.py @@ -1,4 +1,5 @@ import unittest +import time import wx import wx.lib.mixins.inspection as wit @@ -6,6 +7,26 @@ import wx.lib.mixins.inspection as wit class wit_TestCase(unittest.TestCase): + def tearDown(self): + ''' + OnClose can trigger: + AttributeError: 'Crust' object has no attribute 'lastsashpos' + so we'll ensure that the InspectionFrame's crust has that attr. + ''' + windows = wx.GetTopLevelWindows() + for window in windows: + if type(window) == wx.lib.inspection.InspectionFrame: + if hasattr(window, 'crust'): + pass + if not hasattr(window.crust, 'lastsashpos'): + window.crust.lastsashpos = -1 + + # class _InspectionHighlighter's FlickerTLW method invokes + # wx.CallLater(300, self._Toggle, tlw), + # so let's give it a chance to run: + time.sleep(0.3) + super(wit_TestCase, self).tearDown() + def test_App(self): app = wit.InspectableApp()