mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-09-05 01:10:12 +02:00
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'
60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
import unittest
|
|
import time
|
|
import wx
|
|
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()
|
|
|
|
def test_App_OnInit(self):
|
|
class MyApp(wit.InspectableApp):
|
|
def OnInit(self):
|
|
self.onInit_called = True
|
|
self.ShowInspectionTool()
|
|
return True
|
|
app = MyApp()
|
|
self.assertTrue(app.onInit_called)
|
|
|
|
def test_Wit_Mixin(self):
|
|
class MyApp(wx.App, wit.InspectionMixin):
|
|
def OnInit(self):
|
|
self.onInit_called = True
|
|
self.Init()
|
|
self.ShowInspectionTool()
|
|
return True
|
|
app = MyApp()
|
|
self.assertTrue(app.onInit_called)
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|