Exemplo n.º 1
0
 def test_string(self):
     for value in ('x', 'Y', 'z'):
         b = Bool(value, true=('x', 'y', 'z'), false=(1, 2, 3))
         self.assertEqual(str(b), str(value))
     for value in (1, 2, 3):
         b = Bool(value, true=('x', 'y', 'z'), false=(1, 2, 3))
         self.assertEqual(str(b), str(value))
Exemplo n.º 2
0
 def test_truths_and_falsities(self):
     b = Bool('x', true=('x', 'y', 'z'), false=(1, 2, 3))
     self.assertEqual(b.truths, ('x', 'y', 'z'))
     self.assertEqual(b.falsities, (1, 2, 3))
Exemplo n.º 3
0
 def test_valid_values(self):
     self.assertTrue(Bool('x', true=('x', ), false=('o', )))
     self.assertFalse(Bool('O', true=('x', ), false=('o', )))
     with self.assert_raises(ValueError, 'Not a boolean'):
         Bool('0', true=('x', ), false=('o', ))
Exemplo n.º 4
0
 def test_syntax(self):
     self.assertEqual(
         Bool('1', true=('1', 1, 'on'), false=('0', 0, 'off')).syntax,
         '1/0|on/off')