diff --git a/tests/test_converters.py b/tests/test_converters.py index e6e5a3e95..c1a6122ce 100644 --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -134,3 +134,29 @@ class C(object): c = C() assert True is c.a1 is c.a2 + +class TestToBool(object): + def test_unhashable(self): + """ + Fails if value is unhashable. + """ + with pytest.raises(ValueError, match="Cannot convert value to bool"): + to_bool([]) + + + def test_truthy(self): + """ + Fails if truthy values are incorrectly converted. + """ + assert to_bool("t") + assert to_bool("yes") + assert to_bool("on") + + def test_falsy(self): + """ + Fails if falsy values are incorrectly converted. + """ + assert not to_bool("f") + assert not to_bool("no") + assert not to_bool("off") +