From c4f1e9f3bd99d20b1d1f032dac7760933e20adcc Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 10 Nov 2020 14:43:18 -0800 Subject: [PATCH 1/2] Add missing context manager methods for wx.LogNull --- etg/log.py | 6 ++++-- unittests/test_log.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/etg/log.py b/etg/log.py index d0a15627..2558bd5f 100644 --- a/etg/log.py +++ b/etg/log.py @@ -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) diff --git a/unittests/test_log.py b/unittests/test_log.py index 60591dcb..fc43254c 100644 --- a/unittests/test_log.py +++ b/unittests/test_log.py @@ -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 + + #--------------------------------------------------------------------------- From a6e855c34e0d0dfab9914b6f65432263e7a2dadf Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 10 Nov 2020 14:46:15 -0800 Subject: [PATCH 2/2] Add changelog item --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e66dca07..a522b33e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) +