Skip to content

Commit

Permalink
Add to_bool tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Turner committed Aug 6, 2021
1 parent a85ab29 commit 89bcbd8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_converters.py
Expand Up @@ -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")

0 comments on commit 89bcbd8

Please sign in to comment.