Package toon :: Package test :: Module test_optgroups
[hide private]
[frames] | no frames]

Source Code for Module toon.test.test_optgroups

 1  #!/usr/bin/env python 
 2  from toon import optgroup 
 3  from toon import fx 
 4  import unittest 
 5   
6 -class ExampleGroup(optgroup.OptionsGroup):
7 - def __init__(self):
8 self.i = 3 9 self.f = 2.0 10 self.s = "qwe" 11 self.vec4 = [1.0, 0.8, 0.2, 1.0] 12 self.vec3 = [1.0, 0.8, 0.2]
13
14 -class Test_Options(unittest.TestCase):
15 - def test_string_options(self):
16 g = ExampleGroup() 17 g.set_value("i", "4") 18 if g.i != 4: 19 self.fail("The attribute i should have been set to a int with value 4.") 20 g.set_value("f", "4.2") 21 if g.f != 4.2: 22 self.fail("The attribute f should have been set to a float with value 4.2.") 23 g.set_value("s", "asd") 24 if g.s != "asd": 25 self.fail("The attribute s should have been set to a str with value asd.") 26 g.set_value("vec3", "5,6,7.2") 27 if g.vec3[0] != 5.0: 28 self.fail("vec3[0] has a wrong value %s" % (g.vec3[0])) 29 if g.vec3[1] != 6.0: 30 self.fail("vec3[1] has a wrong value %s" % (g.vec3[1])) 31 if g.vec3[2] != 7.2: 32 self.fail("vec3[2] has a wrong value %s" % (g.vec3[2]))
33