File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -1172,12 +1172,12 @@ def allow_style_type(value: str) -> ru.AllowStyle:
1172
1172
@property
1173
1173
def allow_style (self ) -> ru .AllowStyle :
1174
1174
"""Read-only property needed to support do_set when it reads allow_style."""
1175
- return ru .allow_style
1175
+ return ru .ALLOW_STYLE
1176
1176
1177
1177
@allow_style .setter
1178
1178
def allow_style (self , new_val : ru .AllowStyle ) -> None :
1179
1179
"""Setter property needed to support do_set when it updates allow_style."""
1180
- ru .allow_style = new_val
1180
+ ru .ALLOW_STYLE = new_val
1181
1181
1182
1182
def _completion_supported (self ) -> bool :
1183
1183
"""Return whether tab completion is supported."""
Original file line number Diff line number Diff line change 28
28
29
29
30
30
class AllowStyle (Enum ):
31
- """Values for ``cmd2.rich_utils.allow_style ``."""
31
+ """Values for ``cmd2.rich_utils.ALLOW_STYLE ``."""
32
32
33
33
ALWAYS = 'Always' # Always output ANSI style sequences
34
34
NEVER = 'Never' # Remove ANSI style sequences from all output
@@ -44,7 +44,7 @@ def __repr__(self) -> str:
44
44
45
45
46
46
# Controls when ANSI style sequences are allowed in output
47
- allow_style = AllowStyle .TERMINAL
47
+ ALLOW_STYLE = AllowStyle .TERMINAL
48
48
49
49
50
50
class Cmd2Theme (Theme ):
@@ -123,13 +123,13 @@ def __init__(self, file: IO[str] | None = None) -> None:
123
123
force_terminal : bool | None = None
124
124
force_interactive : bool | None = None
125
125
126
- if allow_style == AllowStyle .ALWAYS :
126
+ if ALLOW_STYLE == AllowStyle .ALWAYS :
127
127
force_terminal = True
128
128
129
129
# Turn off interactive mode if dest is not actually a terminal which supports it
130
130
tmp_console = Console (file = file )
131
131
force_interactive = tmp_console .is_interactive
132
- elif allow_style == AllowStyle .NEVER :
132
+ elif ALLOW_STYLE == AllowStyle .NEVER :
133
133
force_terminal = False
134
134
135
135
# Configure console defaults to treat output as plain, unstructured text.
Original file line number Diff line number Diff line change @@ -49,12 +49,12 @@ def arg_decorator(func):
49
49
50
50
@functools .wraps (func )
51
51
def cmd_wrapper (* args , ** kwargs ):
52
- old = ru .allow_style
53
- ru .allow_style = style
52
+ old = ru .ALLOW_STYLE
53
+ ru .ALLOW_STYLE = style
54
54
try :
55
55
retval = func (* args , ** kwargs )
56
56
finally :
57
- ru .allow_style = old
57
+ ru .ALLOW_STYLE = old
58
58
return retval
59
59
60
60
return cmd_wrapper
@@ -244,20 +244,20 @@ def test_set_no_settables(base_app) -> None:
244
244
)
245
245
def test_set_allow_style (base_app , new_val , is_valid , expected ) -> None :
246
246
# Initialize allow_style for this test
247
- ru .allow_style = ru .AllowStyle .TERMINAL
247
+ ru .ALLOW_STYLE = ru .AllowStyle .TERMINAL
248
248
249
249
# Use the set command to alter it
250
250
out , err = run_cmd (base_app , f'set allow_style { new_val } ' )
251
251
assert base_app .last_result is is_valid
252
252
253
253
# Verify the results
254
- assert ru . allow_style == expected
254
+ assert expected == ru . ALLOW_STYLE
255
255
if is_valid :
256
256
assert not err
257
257
assert out
258
258
259
259
# Reset allow_style to its default since it's an application-wide setting that can affect other unit tests
260
- ru .allow_style = ru .AllowStyle .TERMINAL
260
+ ru .ALLOW_STYLE = ru .AllowStyle .TERMINAL
261
261
262
262
263
263
def test_set_with_choices (base_app ) -> None :
You can’t perform that action at this time.
0 commit comments