FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bpython/bpython/test/test_keys.py at main · darrenatrealpython/bpython · GitHub
darrenatrealpython
/
bpython
Public
forked from
bpython/bpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
bpython
/
bpython
/
test
/
test_keys.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (54 loc) · 2.6 KB
Breadcrumbs
bpython
/
bpython
/
test
/
test_keys.py
Copy path
File metadata and controls
69 lines (54 loc) · 2.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import
unittest
from
bpython
import
keys
class
TestCLIKeys
(
unittest
.
TestCase
):
def
test_keymap_map
(
self
):
"""Verify KeyMap.map being a dictionary with the correct
length."""
self
.
assertEqual
(
len
(
keys
.
cli_key_dispatch
.
map
),
43
)
def
test_keymap_setitem
(
self
):
"""Verify keys.KeyMap correctly setting items."""
keys
.
cli_key_dispatch
[
"simon"
]
=
"awesome"
self
.
assertEqual
(
keys
.
cli_key_dispatch
[
"simon"
],
"awesome"
)
def
test_keymap_delitem
(
self
):
"""Verify keys.KeyMap correctly removing items."""
keys
.
cli_key_dispatch
[
"simon"
]
=
"awesome"
del
keys
.
cli_key_dispatch
[
"simon"
]
if
"simon"
in
keys
.
cli_key_dispatch
.
map
:
raise
Exception
(
"Key still exists in dictionary"
)
def
test_keymap_getitem
(
self
):
"""Verify keys.KeyMap correctly looking up items."""
self
.
assertEqual
(
keys
.
cli_key_dispatch
[
"C-["
], (
chr
(
27
),
"^["
))
self
.
assertEqual
(
keys
.
cli_key_dispatch
[
"F11"
], (
"KEY_F(11)"
,))
self
.
assertEqual
(
keys
.
cli_key_dispatch
[
"C-a"
], (
"
\x01
"
,
"^A"
))
def
test_keymap_keyerror
(
self
):
"""Verify keys.KeyMap raising KeyError when getting undefined key"""
with
self
.
assertRaises
(
KeyError
):
keys
.
cli_key_dispatch
[
"C-asdf"
]
keys
.
cli_key_dispatch
[
"C-qwerty"
]
class
TestUrwidKeys
(
unittest
.
TestCase
):
def
test_keymap_map
(
self
):
"""Verify KeyMap.map being a dictionary with the correct
length."""
self
.
assertEqual
(
len
(
keys
.
urwid_key_dispatch
.
map
),
64
)
def
test_keymap_setitem
(
self
):
"""Verify keys.KeyMap correctly setting items."""
keys
.
urwid_key_dispatch
[
"simon"
]
=
"awesome"
self
.
assertEqual
(
keys
.
urwid_key_dispatch
[
"simon"
],
"awesome"
)
def
test_keymap_delitem
(
self
):
"""Verify keys.KeyMap correctly removing items."""
keys
.
urwid_key_dispatch
[
"simon"
]
=
"awesome"
del
keys
.
urwid_key_dispatch
[
"simon"
]
if
"simon"
in
keys
.
urwid_key_dispatch
.
map
:
raise
Exception
(
"Key still exists in dictionary"
)
def
test_keymap_getitem
(
self
):
"""Verify keys.KeyMap correctly looking up items."""
self
.
assertEqual
(
keys
.
urwid_key_dispatch
[
"F11"
],
"f11"
)
self
.
assertEqual
(
keys
.
urwid_key_dispatch
[
"C-a"
],
"ctrl a"
)
self
.
assertEqual
(
keys
.
urwid_key_dispatch
[
"M-a"
],
"meta a"
)
def
test_keymap_keyerror
(
self
):
"""Verify keys.KeyMap raising KeyError when getting undefined key"""
with
self
.
assertRaises
(
KeyError
):
keys
.
urwid_key_dispatch
[
"C-asdf"
]
keys
.
urwid_key_dispatch
[
"C-qwerty"
]
if
__name__
==
"__main__"
:
unittest
.
main
()
Back
|
FazBrowse Home
|
New Git URL