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.")
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.')
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.'
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."
def test_string_truthy(self): """Test with "truthy" strings.""" for s in ('t', 'true', 'y', 'yes', 'on', '1'): assert config._validate_bool(s)
def test_string_falsey(self): """Test with "falsey" strings.""" for s in ('f', 'false', 'n', 'no', 'off', '0'): assert not config._validate_bool(s)
def test_bool(self): """Test with boolean values.""" assert not config._validate_bool(False) assert config._validate_bool(True)
def test_bool(self): """Test with boolean values.""" self.assertTrue(config._validate_bool(False) is False) self.assertTrue(config._validate_bool(True) is True)