Merge pull request #1845 from wxWidgets/fix-issue1842

Add context manager methods to wx.LogNull
This commit is contained in:
Robin Dunn
2020-11-10 16:13:19 -08:00
committed by GitHub
3 changed files with 12 additions and 2 deletions

View File

@@ -79,6 +79,8 @@ New and improved in this release:
was done to workaround a bug in wxMac, but it seems worthwhile enough to keep
it around even after the bug was fixed.
* Added the missing context manager methods for wx.LogNull. (#1842)

View File

@@ -116,11 +116,13 @@ def run():
c.addPrivateCopyCtor()
c.addPrivateAssignOp()
c = module.find('wxLogFormatter')
c.find('FormatTime').ignore(False)
c = module.find('wxLogNull')
c.addPyMethod('__enter__', '(self)', 'return self')
c.addPyMethod('__exit__', '(self, exc_type, exc_val, exc_tb)', 'return False')
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -23,6 +23,12 @@ class log_Tests(wtc.WidgetTestCase):
wx.LogMessage("This is a test")
self.assertTrue(log.messageLogged)
def test_lognull_is_context_mgr(self):
with wx.LogNull():
pass
#---------------------------------------------------------------------------