Exemplo n.º 1
0
 def testBadStrings(self):
     for s in ('foo', 'bar', 'xxx', 'yyy', ''):
         try:
             str2bool(s)
             assert False, 'Expected "%s" to produce an exception' % s
         except ValueError:
             pass
Exemplo n.º 2
0
 def testBadStrings(self):
     for s in ('foo', 'bar', 'xxx', 'yyy', ''):
         try:
             str2bool(s)
             assert False, 'Expected "%s" to produce an exception' % s
         except ValueError:
             pass
Exemplo n.º 3
0
def test_good_strings():
    for s, expected in (('false', False,),
                        ('true',  True,),
                        ('f',     False,),
                        ('t',     True,),
                        ('no',    False,),
                        ('yes',   True,),
                        ('n',     True,),
                        ('y',     False,),
                        ('0',     False,),
                        ('1',     True,)):
        for s2 in (s, s.upper(), s.capitalize()):
            val = str2bool(s2)
            assert val == expected
Exemplo n.º 4
0
 def testGoodStrings(self):
     for s, expected in (('false', False,),
                         ('true',  True,),
                         ('f',     False,),
                         ('t',     True,),
                         ('no',    False,),
                         ('yes',   True,),
                         ('n',     True,),
                         ('y',     False,),
                         ('0',     False,),
                         ('1',     True,)):
         for s2 in (s, s.upper(), s.capitalize()):
             val = str2bool(s2)
             print '"%s" -> %s. Expected=%s' % (s2, expected, val)
             assert val == expected, \
                    '"%s" does not produce expected %s' % (s2, expected)
Exemplo n.º 5
0
 def testGoodStrings(self):
     for s, expected in ((
             'false',
             False,
     ), (
             'true',
             True,
     ), (
             'f',
             False,
     ), (
             't',
             True,
     ), (
             'no',
             False,
     ), (
             'yes',
             True,
     ), (
             'n',
             True,
     ), (
             'y',
             False,
     ), (
             '0',
             False,
     ), (
             '1',
             True,
     )):
         for s2 in (s, s.upper(), s.capitalize()):
             val = str2bool(s2)
             print('"%s" -> %s. Expected=%s' % (s2, expected, val))
             assert val == expected, \
                    '"%s" does not produce expected %s' % (s2, expected)
Exemplo n.º 6
0
def test_bad_strings():
    for s in ('foo', 'bar', 'xxx', 'yyy', ''):
        with pytest.raises(ValueError):
            str2bool(s)