Beispiel #1
0
    def test_bool_opt_casts(self):
        conf = Config({'section1': {'help': 'no', 'bool': True}})
        value = conf.bool('section1', 'help', True)
        self.assertEquals(value, False)
        value = conf.bool('section1', 'bool', True)
        self.assertEquals(value, True)

        def truthy_test(value, expected):
            conf = Config({'section1': {'verbose': value}})
            value = conf.bool('section1', 'verbose', True)
            self.assertEquals(value, expected)

        truthy_test('TRUE', True)
        truthy_test('True', True)
        truthy_test('true', True)
        truthy_test('YES', True)
        truthy_test('yes', True)
        truthy_test('Yes', True)
        truthy_test('T', True)
        truthy_test('t', True)
        truthy_test('Y', True)
        truthy_test('y', True)
        truthy_test('1', True)
        truthy_test('ON', True)
        truthy_test('On', True)
        truthy_test('on', True)
        truthy_test('ENABLE', True)
        truthy_test('Enable', True)
        truthy_test('enable', True)
        truthy_test(True, True)
Beispiel #2
0
    def test_bool_opts(self):
        conf = Config()
        value = conf.bool('section1', 'bool', True)
        self.assertEquals(value, True)

        conf = Config({'section1': {'bool': False}})
        value = conf.bool('section1', 'bool', True)
        self.assertEquals(value, False)
Beispiel #3
0
 def truthy_test(value, expected):
     conf = Config({'section1': {'verbose': value}})
     value = conf.bool('section1', 'verbose', True)
     self.assertEquals(value, expected)