1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
import unittest
from unittests import wtc
import wx
import wx.lib.masked as m
#---------------------------------------------------------------------------
class MaskedComboBoxTests(wtc.WidgetTestCase):
def test_ComboBoxCtors(self):
c = m.ComboBox(self.frame, value='value', choices="one two three four".split())
c = m.ComboBox(self.frame, -1, 'value', wx.Point(10,10), wx.Size(80,-1),
"one two three four".split(), 0)
c = m.ComboBox(self.frame, -1, "", (10,10), (80,-1), "one two three four".split(), 0)
self.assertTrue(c.GetCount() == 4)
#def test_ComboBoxDefaultCtor(self):
#c = m.PreMaskedComboBox(self.frame)
#c.Create(self.frame, value="value", choices="one two three four".split())
#---------------------------------------------------------------------------
class MaskedTextCtrlTests(wtc.WidgetTestCase):
def test_textctrlCtor(self):
t = m.TextCtrl(self.frame)
t = m.TextCtrl(self.frame, -1, "Hello")
t = m.TextCtrl(self.frame, style=wx.TE_READONLY)
t = m.TextCtrl(self.frame, style=wx.TE_PASSWORD)
t = m.TextCtrl(self.frame, style=wx.TE_MULTILINE)
#def test_textctrlDefaultCtor(self):
#t = m.TextCtrl()
#t.Create(self.frame)
def test_textctrlProperties(self):
t = m.TextCtrl(self.frame)
t.DefaultStyle
t.NumberOfLines
t.Hint
t.InsertionPoint
t.LastPosition
t.Margins
t.StringSelection
t.Value
#---------------------------------------------------------------------------
class MaskedNumCtrlTests(wtc.WidgetTestCase):
def test_numctrlCtor(self):
t1 = m.NumCtrl(self.frame)
t2 = m.NumCtrl(self.frame, -1, "10")
t3 = m.NumCtrl(self.frame, value='32',style=wx.TE_READONLY, min=32, max=72)
t3.ChangeValue("16")
self.assertTrue(not t3.IsValid())
#def test_numctrlDefaultCtor(self):
#t = m.TextCtrl()
#t.Create(self.frame)
def test_numctrlProperties(self):
t = m.NumCtrl(self.frame)
t.DefaultStyle
t.NumberOfLines
t.Hint
t.InsertionPoint
t.LastPosition
t.Margins
t.StringSelection
t.Value
#---------------------------------------------------------------------------
class MaskedTimeCtrlTests(wtc.WidgetTestCase):
def test_timectrlCtor(self):
t = m.TimeCtrl(self.frame)
t = m.TimeCtrl(self.frame, -1, "18:00:00")
t = m.TimeCtrl(self.frame, style=wx.TE_READONLY)
#def test_numctrlDefaultCtor(self):
#t = m.TextCtrl()
#t.Create(self.frame)
def test_timectrlIsValid(self):
t = m.TimeCtrl(self.frame, -1, "18:25:18")
theTime = t.GetValue(as_wxDateTime=True)
self.assertEqual(theTime.hour, 18, "Hour: %s instead of '18'" % theTime.hour)
self.assertEqual(theTime.minute, 25, "Minutes: %s instead of '18'" % theTime.minute)
self.assertEqual(theTime.second, 18, "Seconds: %s instead of '18'" % theTime.second)
self.assertEqual(t.IsInBounds(), True)
self.assertEqual(t.GetCtrlParameter('validBackgroundColour'), t.GetBackgroundColour())
def test_timectrlProperties(self):
t = m.TimeCtrl(self.frame)
t.DefaultStyle
t.NumberOfLines
t.Hint
t.InsertionPoint
t.LastPosition
t.Margins
t.StringSelection
t.Value
#---------------------------------------------------------------------------
class MaskedIpAddrCtrlTests(wtc.WidgetTestCase):
def test_ipaddrctrlCtor(self):
t = m.IpAddrCtrl(self.frame)
t = m.IpAddrCtrl(self.frame, -1, "128.000.000.000")
t = m.IpAddrCtrl(self.frame, style=wx.TE_READONLY)
#def test_ipaddrctrlDefaultCtor(self):
#t = m.IpAddrCtrl()
#t.Create(self.frame)
def test_ipaddrctrlProperties(self):
t = m.IpAddrCtrl(self.frame)
t.DefaultStyle
t.NumberOfLines
t.Hint
t.InsertionPoint
t.LastPosition
t.Margins
t.StringSelection
t.Value
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
|