Skip to content

Commit

Permalink
Fix case sensitivity
Browse files Browse the repository at this point in the history
Thanks @mirekdlugosz for the patch in issue SatelliteQE#148
Just me stealing his code and committing it

Resolves validation failing valid token values when case sensitivity is set to true
  • Loading branch information
mshriver committed Nov 24, 2020
1 parent d1ca184 commit 04b276c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions testimony/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def __init__(self, name, config):
if self.token_type == 'choice':
assert 'choices' in config
assert isinstance(config['choices'], list)
casesensitive = config.get('casesensitive', True)
self.choices = [i if casesensitive else i.lower()
self.casesensitive = config.get('casesensitive', True)
self.choices = [i if self.casesensitive else i.lower()
for i in config['choices']]

def update(self, new_values):
Expand All @@ -87,5 +87,7 @@ def update(self, new_values):
def validate(self, what):
"""Ensure that 'what' meets value validation criteria."""
if self.token_type == 'choice':
return what.lower() in self.choices
if not self.casesensitive:
what = what.lower()
return what in self.choices
return True # assume valid for unknown types

0 comments on commit 04b276c

Please sign in to comment.