mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-09 20:37:46 +00:00
Case insensitive check for boolean validation
This commit is contained in:
@@ -131,9 +131,9 @@ def boolean(s):
|
||||
>>> boolean('false')
|
||||
False
|
||||
'''
|
||||
if s in ['true', 'True']:
|
||||
if s.lower() == 'true':
|
||||
return True
|
||||
elif s in ['false', 'False']:
|
||||
elif s.lower() == 'false':
|
||||
return False
|
||||
else:
|
||||
raise ValueError('Invalid boolean value')
|
||||
|
||||
@@ -34,8 +34,10 @@ def test_get_function_from_name_for_class_method():
|
||||
def test_boolean():
|
||||
assert utils.boolean('true')
|
||||
assert utils.boolean('True')
|
||||
assert utils.boolean('TRUE')
|
||||
assert not utils.boolean('false')
|
||||
assert not utils.boolean('False')
|
||||
assert not utils.boolean('FALSE')
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
utils.boolean('foo')
|
||||
|
||||
Reference in New Issue
Block a user