Skip to content

Commit

Permalink
#552 Strip output symbol (#556)
Browse files Browse the repository at this point in the history
* #537 Removed shebangs in non-executables

* strip output_symbol
  • Loading branch information
sezanzeb committed Nov 23, 2022
1 parent d2fc5a6 commit 9a4c870
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions inputremapper/configs/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ def validate_symbol(cls, symbol):
if not symbol:
return None

symbol = symbol.strip()

if is_this_a_macro(symbol):
try:
parse(symbol, verbose=False) # raises MacroParsingError
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ def test_get_output_type_code(self):
m = Mapping(**cfg)
a = system_mapping.get("a")
self.assertEqual(m.get_output_type_code(), (EV_KEY, a))

m.output_symbol = "key(a)"
self.assertIsNone(m.get_output_type_code())

cfg = {
"event_combination": "1,2,1+3,1,0",
"target_uinput": "keyboard",
Expand All @@ -154,6 +156,16 @@ def test_get_output_type_code(self):
m = Mapping(**cfg)
self.assertEqual(m.get_output_type_code(), (2, 3))

def test_strips_output_symbol(self):
cfg = {
"event_combination": "1,2,1",
"target_uinput": "keyboard",
"output_symbol": "\t a \n",
}
m = Mapping(**cfg)
a = system_mapping.get("a")
self.assertEqual(m.get_output_type_code(), (EV_KEY, a))

def test_init_sets_event_actions(self):
"""Test that InputEvent.actions are set properly."""
cfg = {
Expand Down

0 comments on commit 9a4c870

Please sign in to comment.