mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-09-05 17:30:26 +02:00
* Use the new yield * Add some new tests git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69194 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
import imp_unittest, unittest
|
|
import wtc
|
|
import wx
|
|
import os
|
|
|
|
cfgFilename = os.path.join(os.path.dirname(__file__), 'cfgtest')
|
|
#---------------------------------------------------------------------------
|
|
|
|
class ConfigTests(wtc.WidgetTestCase):
|
|
|
|
def test_Config1(self):
|
|
null = wx.LogNull()
|
|
name = cfgFilename + '_1'
|
|
cfg = wx.Config('unittest_ConfigTests', localFilename=name)
|
|
self.writeStuff(cfg)
|
|
del cfg
|
|
if os.path.exists(name):
|
|
os.remove(name)
|
|
|
|
def writeStuff(self, cfg):
|
|
cfg.SetPath('/one/two/three')
|
|
cfg.Write('key', 'value')
|
|
cfg.WriteInt('int', 123)
|
|
cfg.WriteFloat('float', 123.456)
|
|
cfg.WriteBool('bool', True)
|
|
cfg.Flush()
|
|
|
|
|
|
|
|
def test_Config2(self):
|
|
null = wx.LogNull()
|
|
name = cfgFilename + '_2'
|
|
|
|
wx.Config.Set(wx.Config('unittest_ConfigTests', localFilename=name))
|
|
cfg = wx.Config.Get()
|
|
self.writeStuff(cfg)
|
|
del cfg
|
|
|
|
cfg = wx.Config.Get()
|
|
cfg.SetPath('/one/two/three')
|
|
self.assertTrue(cfg.GetPath() == '/one/two/three')
|
|
self.assertTrue(cfg.GetNumberOfEntries() == 4)
|
|
self.assertTrue(cfg.Read('key') == 'value')
|
|
self.assertTrue(cfg.ReadInt('int') == 123)
|
|
self.assertTrue(cfg.ReadFloat('float') == 123.456)
|
|
self.assertTrue(cfg.ReadBool('bool') == True)
|
|
self.assertTrue(cfg.Read('no-value', 'defvalue') == 'defvalue')
|
|
|
|
if os.path.exists(name):
|
|
os.remove(name)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|