Skip to content

Commit

Permalink
Merge pull request #1065 from benoit-pierre/fix_config_keymap_validation
Browse files Browse the repository at this point in the history
config: fix keymap validation
  • Loading branch information
TheaMorin authored Apr 30, 2019
2 parents e8ba565 + c873f2b commit d4ace92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plover/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ def setter(config, key, keymap):
def validate(config, key, value):
try:
return build_keymap(config, key, value)
except ValueError as e:
raise InvalidConfigOption(value, default(config, machine_type, system_name)) from e
except (TypeError, ValueError) as e:
raise InvalidConfigOption(value, default(config, key)) from e
return ConfigOption('system_keymap', default, getter, setter, validate, full_key)

def dictionaries_option():
Expand Down
22 changes: 22 additions & 0 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,28 @@ def test_config_dict():
'''
),

('invalid_keymap_1',
'''
[System: English Stenotype]
keymap[keyboard] = [["_-"]]
''',
DEFAULTS,
{},
{},
None,
),

('invalid_keymap_2',
'''
[System: English Stenotype]
keymap[keyboard] = 42
''',
DEFAULTS,
{},
{},
None,
),

('invalid_options_1',
'''
[System]
Expand Down

0 comments on commit d4ace92

Please sign in to comment.