Skip to content

Commit

Permalink
Allow None value in boolean converter
Browse files Browse the repository at this point in the history
  • Loading branch information
cyprien-g committed Jan 4, 2016
1 parent 754c250 commit 41df524
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion connexion/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def boolean(s):
>>> boolean('false')
False
'''
if s.lower() == 'true':
if not hasattr(s, 'lower'):
raise ValueError('Invalid boolean value')
elif s.lower() == 'true':
return True
elif s.lower() == 'false':
return False
Expand Down
3 changes: 3 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ def test_boolean():

with pytest.raises(ValueError):
utils.boolean('foo')

with pytest.raises(ValueError):
utils.boolean(None)

0 comments on commit 41df524

Please sign in to comment.