MCPcopy Index your code
hub / github.com/python/cpython / test_keyspec_errors

Method test_keyspec_errors

Lib/test/test_pyrepl/test_keymap.py:51–68  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

49 self.assertEqual(parse_keys("\\M-a\\t\\<down>"), ["\033", "a", "\t", "down"])
50
51 def test_keyspec_errors(self):
52 cases = [
53 ("\\Ca", "\\C must be followed by `-'"),
54 ("\\ca", "\\C must be followed by `-'"),
55 ("\\C-\\C-", "doubled \\C-"),
56 ("\\Ma", "\\M must be followed by `-'"),
57 ("\\ma", "\\M must be followed by `-'"),
58 ("\\M-\\M-", "doubled \\M-"),
59 ("\\<left", "unterminated \\<"),
60 ("\\<unsupported>", "unrecognised keyname"),
61 ("\\大", "unknown backslash escape"),
62 ("\\C-\\<backspace>", "\\C- followed by invalid key")
63 ]
64 for test_keys, expected_err in cases:
65 with self.subTest(f"{test_keys} should give error {expected_err}"):
66 with self.assertRaises(KeySpecError) as e:
67 parse_keys(test_keys)
68 self.assertIn(expected_err, str(e.exception))
69
70 def test_index_errors(self):
71 test_cases = ["\\", "\\C", "\\C-\\C"]

Callers

nothing calls this directly

Calls 5

parse_keysFunction · 0.90
strFunction · 0.85
assertInMethod · 0.80
subTestMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected