From bea3258b0b27eb88b976f3931d8bdb08e97b427c Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 13 Apr 2013 01:46:09 +0000 Subject: [PATCH] Ignore the GetFirst/GetNext methods in wx.FileConfig so it will use the custom ones in wx.ConfigBase instead. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73813 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/config.py | 15 ++++++++---- unittests/test_config.py | 50 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/etg/config.py b/etg/config.py index d343c209..7806c3a1 100644 --- a/etg/config.py +++ b/etg/config.py @@ -162,12 +162,19 @@ def run(): #----------------------------------------------------------------- c = module.find('wxFileConfig') c.addPrivateCopyCtor() - c.find('wxFileConfig').findOverload('wxInputStream').ignore() - ctor = c.find('wxFileConfig').findOverload('wxString') - ctor.items.remove(ctor.find('conv')) - ctor = c.find('Save').ignore() + c.find('wxFileConfig').findOverload('wxInputStream').find('conv').ignore() + ctor = c.find('wxFileConfig').findOverload('wxString').find('conv').ignore() + #ctor.items.remove(ctor.find('conv')) + ctor = c.find('Save').find('conv').ignore() c.find('GetGlobalFile').ignore() c.find('GetLocalFile').ignore() + + c.find('GetFirstGroup').ignore() + c.find('GetNextGroup').ignore() + c.find('GetFirstEntry').ignore() + c.find('GetNextEntry').ignore() + + #----------------------------------------------------------------- # In C++ wxConfig is a #define to some other config class. We'll let our diff --git a/unittests/test_config.py b/unittests/test_config.py index 69e8b6db..c0dc0b57 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -65,7 +65,7 @@ class ConfigTests(wtc.WidgetTestCase): os.remove(name) - def _test_Config4(self): # disabled for now... + def test_Config4(self): # disabled for now... null = wx.LogNull() name = cfgFilename + '_4' @@ -139,6 +139,54 @@ class ConfigTests(wtc.WidgetTestCase): del cfg if os.path.exists(name): os.remove(name) + + + def test_Config6(self): + null = wx.LogNull() + name = cfgFilename + '_6' + + cfg = wx.FileConfig('unittest_ConfigTests', localFilename=name) + cfg.SetPath('/zero') + cfg.Write('key1', 'value') + cfg.Write('key2', 'value') + cfg.Write('key3', 'value') + + cfg.SetPath('/one') + cfg.Write('key1', 'value') + cfg.Write('key2', 'value') + cfg.Write('key3', 'value') + + cfg.SetPath('/two') + cfg.Write('key1', 'value') + cfg.Write('key2', 'value') + cfg.Write('key3', 'value') + + cfg.SetPath('/three') + cfg.Write('key1', 'value') + cfg.Write('key2', 'value') + cfg.Write('key3', 'value') + + cfg.Flush() + + cfg.SetPath('/') + count = 0 + more, group, index = cfg.GetFirstGroup() + while more: + count += 1 + more, group, index = cfg.GetNextGroup(index) + self.assertEqual(count, 4) + + cfg.SetPath('/two') + count = 0 + more, entry, index = cfg.GetFirstEntry() + while more: + count += 1 + more, entry, index = cfg.GetNextEntry(index) + self.assertEqual(count, 3) + + del cfg + if os.path.exists(name): + os.remove(name) #---------------------------------------------------------------------------