aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/tests/test_cli_commands.py
diff options
context:
space:
mode:
authorErovia <Erovia@users.noreply.github.com>2020-11-16 21:09:32 +0000
committerGitHub <noreply@github.com>2020-11-16 21:09:32 +0000
commitb337ba798e23876870f8daf415bc929c0b5382fa (patch)
tree60ad63e1a8b8a33583f67a3617ad10c7c117c3c9 /lib/python/qmk/tests/test_cli_commands.py
parent94e94ffb5bbe61b5da4aad205016923746010b23 (diff)
downloadqmk_firmware-b337ba798e23876870f8daf415bc929c0b5382fa.tar.gz
qmk_firmware-b337ba798e23876870f8daf415bc929c0b5382fa.zip
CLI: Udev related fixes and improvements (#10736)
Diffstat (limited to 'lib/python/qmk/tests/test_cli_commands.py')
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index df5f047da..dd0c572a7 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -13,14 +13,14 @@ def check_subcommand(command, *args):
13 return result 13 return result
14 14
15 15
16def check_returncode(result, expected=0): 16def check_returncode(result, expected=[0]):
17 """Print stdout if `result.returncode` does not match `expected`. 17 """Print stdout if `result.returncode` does not match `expected`.
18 """ 18 """
19 if result.returncode != expected: 19 if result.returncode not in expected:
20 print('`%s` stdout:' % ' '.join(result.args)) 20 print('`%s` stdout:' % ' '.join(result.args))
21 print(result.stdout) 21 print(result.stdout)
22 print('returncode:', result.returncode) 22 print('returncode:', result.returncode)
23 assert result.returncode == expected 23 assert result.returncode in expected
24 24
25 25
26def test_cformat(): 26def test_cformat():
@@ -45,7 +45,7 @@ def test_flash():
45 45
46def test_flash_bootloaders(): 46def test_flash_bootloaders():
47 result = check_subcommand('flash', '-b') 47 result = check_subcommand('flash', '-b')
48 check_returncode(result, 1) 48 check_returncode(result, [1])
49 49
50 50
51def test_config(): 51def test_config():
@@ -62,7 +62,7 @@ def test_kle2json():
62 62
63def test_doctor(): 63def test_doctor():
64 result = check_subcommand('doctor', '-n') 64 result = check_subcommand('doctor', '-n')
65 check_returncode(result) 65 check_returncode(result, [0, 1])
66 assert 'QMK Doctor is checking your environment.' in result.stdout 66 assert 'QMK Doctor is checking your environment.' in result.stdout
67 assert 'QMK is ready to go' in result.stdout 67 assert 'QMK is ready to go' in result.stdout
68 68
@@ -89,43 +89,43 @@ def test_list_keyboards():
89 89
90def test_list_keymaps(): 90def test_list_keymaps():
91 result = check_subcommand('list-keymaps', '-kb', 'handwired/onekey/pytest') 91 result = check_subcommand('list-keymaps', '-kb', 'handwired/onekey/pytest')
92 check_returncode(result, 0) 92 check_returncode(result)
93 assert 'default' and 'test' in result.stdout 93 assert 'default' and 'test' in result.stdout
94 94
95 95
96def test_list_keymaps_long(): 96def test_list_keymaps_long():
97 result = check_subcommand('list-keymaps', '--keyboard', 'handwired/onekey/pytest') 97 result = check_subcommand('list-keymaps', '--keyboard', 'handwired/onekey/pytest')
98 check_returncode(result, 0) 98 check_returncode(result)
99 assert 'default' and 'test' in result.stdout 99 assert 'default' and 'test' in result.stdout
100 100
101 101
102def test_list_keymaps_kb_only(): 102def test_list_keymaps_kb_only():
103 result = check_subcommand('list-keymaps', '-kb', 'niu_mini') 103 result = check_subcommand('list-keymaps', '-kb', 'niu_mini')
104 check_returncode(result, 0) 104 check_returncode(result)
105 assert 'default' and 'via' in result.stdout 105 assert 'default' and 'via' in result.stdout
106 106
107 107
108def test_list_keymaps_vendor_kb(): 108def test_list_keymaps_vendor_kb():
109 result = check_subcommand('list-keymaps', '-kb', 'ai03/lunar') 109 result = check_subcommand('list-keymaps', '-kb', 'ai03/lunar')
110 check_returncode(result, 0) 110 check_returncode(result)
111 assert 'default' and 'via' in result.stdout 111 assert 'default' and 'via' in result.stdout
112 112
113 113
114def test_list_keymaps_vendor_kb_rev(): 114def test_list_keymaps_vendor_kb_rev():
115 result = check_subcommand('list-keymaps', '-kb', 'kbdfans/kbd67/mkiirgb/v2') 115 result = check_subcommand('list-keymaps', '-kb', 'kbdfans/kbd67/mkiirgb/v2')
116 check_returncode(result, 0) 116 check_returncode(result)
117 assert 'default' and 'via' in result.stdout 117 assert 'default' and 'via' in result.stdout
118 118
119 119
120def test_list_keymaps_no_keyboard_found(): 120def test_list_keymaps_no_keyboard_found():
121 result = check_subcommand('list-keymaps', '-kb', 'asdfghjkl') 121 result = check_subcommand('list-keymaps', '-kb', 'asdfghjkl')
122 check_returncode(result, 1) 122 check_returncode(result, [1])
123 assert 'does not exist' in result.stdout 123 assert 'does not exist' in result.stdout
124 124
125 125
126def test_json2c(): 126def test_json2c():
127 result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json') 127 result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json')
128 check_returncode(result, 0) 128 check_returncode(result)
129 assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n' 129 assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n'
130 130
131 131