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'
This commit is contained in:
James Wettenhall
2017-03-23 22:02:13 +11:00
parent f5aca9d312
commit de9edce1b1

View File

@@ -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()