Ejemplo n.º 1
0
    def test_other(self):
        """Test with a non-string and non-bool type."""
        with self.assertRaises(ValueError) as exc:
            config._validate_bool({'not a': 'bool'})

        self.assertEqual(str(exc.exception),
                         "\"{'not a': 'bool'}\" is not a bool or a string.")
Ejemplo n.º 2
0
    def test_string_other(self):
        """Test with an ambiguous string."""
        with self.assertRaises(ValueError) as exc:
            config._validate_bool('oops typo')

        self.assertEqual(str(exc.exception),
                         '"oops typo" cannot be interpreted as a boolean value.')
Ejemplo n.º 3
0
    def test_string_other(self):
        """Test with an ambiguous string."""
        with pytest.raises(ValueError) as exc:
            config._validate_bool('oops typo')

        assert str(exc.value
                   ) == '"oops typo" cannot be interpreted as a boolean value.'
Ejemplo n.º 4
0
    def test_other(self):
        """Test with a non-string and non-bool type."""
        with pytest.raises(ValueError) as exc:
            config._validate_bool({'not a': 'bool'})

        assert str(
            exc.value) == "\"{'not a': 'bool'}\" is not a bool or a string."
Ejemplo n.º 5
0
 def test_string_truthy(self):
     """Test with "truthy" strings."""
     for s in ('t', 'true', 'y', 'yes', 'on', '1'):
         assert config._validate_bool(s)
Ejemplo n.º 6
0
 def test_string_falsey(self):
     """Test with "falsey" strings."""
     for s in ('f', 'false', 'n', 'no', 'off', '0'):
         assert not config._validate_bool(s)
Ejemplo n.º 7
0
 def test_bool(self):
     """Test with boolean values."""
     assert not config._validate_bool(False)
     assert config._validate_bool(True)
Ejemplo n.º 8
0
 def test_bool(self):
     """Test with boolean values."""
     self.assertTrue(config._validate_bool(False) is False)
     self.assertTrue(config._validate_bool(True) is True)