From c4f1e9f3bd99d20b1d1f032dac7760933e20adcc Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 10 Nov 2020 14:43:18 -0800 Subject: [PATCH] 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 + + #---------------------------------------------------------------------------