Skip to content

Commit 6946e57

Browse files
committed
Removed more terminal code from coverage
1 parent 87551d5 commit 6946e57

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

cmd2/rl_utils.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class RlType(Enum):
4040
import atexit
4141

4242
# Check if we are running in a terminal
43-
if sys.stdout.isatty():
43+
if sys.stdout.isatty(): # pragma: no cover
4444
# noinspection PyPep8Naming
4545
def enable_win_vt100(handle: HANDLE) -> bool:
4646
"""
@@ -121,7 +121,7 @@ def pyreadline_remove_history_item(pos: int) -> None:
121121

122122

123123
# noinspection PyProtectedMember
124-
def rl_force_redisplay() -> None:
124+
def rl_force_redisplay() -> None: # pragma: no cover
125125
"""
126126
Causes readline to display the prompt and input text wherever the cursor is and start
127127
reading input from this location. This is the proper way to restore the input line after
@@ -130,59 +130,59 @@ def rl_force_redisplay() -> None:
130130
if not sys.stdout.isatty():
131131
return
132132

133-
if rl_type == RlType.GNU: # pragma: no cover
133+
if rl_type == RlType.GNU:
134134
readline_lib.rl_forced_update_display()
135135

136136
# After manually updating the display, readline asks that rl_display_fixed be set to 1 for efficiency
137137
display_fixed = ctypes.c_int.in_dll(readline_lib, "rl_display_fixed")
138138
display_fixed.value = 1
139139

140-
elif rl_type == RlType.PYREADLINE: # pragma: no cover
140+
elif rl_type == RlType.PYREADLINE:
141141
# Call _print_prompt() first to set the new location of the prompt
142142
readline.rl.mode._print_prompt()
143143
readline.rl.mode._update_line()
144144

145145

146146
# noinspection PyProtectedMember
147-
def rl_get_point() -> int:
147+
def rl_get_point() -> int: # pragma: no cover
148148
"""
149149
Returns the offset of the current cursor position in rl_line_buffer
150150
"""
151-
if rl_type == RlType.GNU: # pragma: no cover
151+
if rl_type == RlType.GNU:
152152
return ctypes.c_int.in_dll(readline_lib, "rl_point").value
153153

154-
elif rl_type == RlType.PYREADLINE: # pragma: no cover
154+
elif rl_type == RlType.PYREADLINE:
155155
return readline.rl.mode.l_buffer.point
156156

157-
else: # pragma: no cover
157+
else:
158158
return 0
159159

160160

161161
# noinspection PyProtectedMember
162-
def rl_set_prompt(prompt: str) -> None:
162+
def rl_set_prompt(prompt: str) -> None: # pragma: no cover
163163
"""
164164
Sets readline's prompt
165165
:param prompt: the new prompt value
166166
"""
167167
safe_prompt = rl_make_safe_prompt(prompt)
168168

169-
if rl_type == RlType.GNU: # pragma: no cover
169+
if rl_type == RlType.GNU:
170170
encoded_prompt = bytes(safe_prompt, encoding='utf-8')
171171
readline_lib.rl_set_prompt(encoded_prompt)
172172

173-
elif rl_type == RlType.PYREADLINE: # pragma: no cover
173+
elif rl_type == RlType.PYREADLINE:
174174
readline.rl._set_prompt(safe_prompt)
175175

176176

177-
def rl_make_safe_prompt(prompt: str, start: str = "\x01", end: str = "\x02") -> str:
177+
def rl_make_safe_prompt(prompt: str, start: str = "\x01", end: str = "\x02") -> str: # pragma: no cover
178178
"""Overcome bug in GNU Readline in relation to calculation of prompt length in presence of ANSI escape codes.
179179
180180
:param prompt: original prompt
181181
:param start: start code to tell GNU Readline about beginning of invisible characters
182182
:param end: end code to tell GNU Readline about end of invisible characters
183183
:return: prompt safe to pass to GNU Readline
184184
"""
185-
if rl_type == RlType.GNU: # pragma: no cover
185+
if rl_type == RlType.GNU:
186186
escaped = False
187187
result = ""
188188

0 commit comments

Comments
 (0)