File tree Expand file tree Collapse file tree 1 file changed +43
-5
lines changed Expand file tree Collapse file tree 1 file changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -1069,13 +1069,51 @@ def test_cmdloop_without_rawinput() -> None:
1069
1069
1070
1070
1071
1071
def test_cmdfinalizations_runs (base_app , monkeypatch ) -> None :
1072
- """Make sure _run_cmdfinalization_hooks is run on after each command."""
1073
- with mock .patch ('sys.stdin.isatty' , mock .MagicMock (name = 'isatty' , return_value = True )):
1074
- m = mock .MagicMock (name = 'cmdfinalization' )
1075
- monkeypatch .setattr ("cmd2.Cmd._run_cmdfinalization_hooks" , m )
1072
+ """Make sure _run_cmdfinalization_hooks is run after each command."""
1073
+ termios_settings = [
1074
+ 27394 ,
1075
+ 3 ,
1076
+ 19200 ,
1077
+ 536872399 ,
1078
+ 38400 ,
1079
+ 38400 ,
1080
+ [
1081
+ b'\x04 ' ,
1082
+ b'\xff ' ,
1083
+ b'\xff ' ,
1084
+ b'\x7f ' ,
1085
+ b'\x17 ' ,
1086
+ b'\x15 ' ,
1087
+ b'\x12 ' ,
1088
+ b'\x00 ' ,
1089
+ b'\x03 ' ,
1090
+ b'\x1c ' ,
1091
+ b'\x1a ' ,
1092
+ b'\x19 ' ,
1093
+ b'\x11 ' ,
1094
+ b'\x13 ' ,
1095
+ b'\x16 ' ,
1096
+ b'\x0f ' ,
1097
+ b'\x01 ' ,
1098
+ b'\x00 ' ,
1099
+ b'\x14 ' ,
1100
+ b'\x00 ' ,
1101
+ ],
1102
+ ]
1103
+
1104
+ base_app ._initial_termios_settings = termios_settings
1105
+ with (
1106
+ mock .patch ('sys.stdin.isatty' , mock .MagicMock (name = 'isatty' , return_value = True )),
1107
+ mock .patch ('sys.stdin.fileno' , mock .MagicMock (name = 'fileno' , return_value = 0 )),
1108
+ ):
1109
+ monkeypatch .setattr (base_app .stdin , "fileno" , lambda : 0 )
1110
+ monkeypatch .setattr (base_app .stdin , "isatty" , lambda : True )
1111
+
1112
+ cmd_fin = mock .MagicMock (name = 'cmdfinalization' )
1113
+ monkeypatch .setattr ("cmd2.Cmd._run_cmdfinalization_hooks" , cmd_fin )
1076
1114
1077
1115
base_app .onecmd_plus_hooks ('help' )
1078
- m .assert_called_once ()
1116
+ cmd_fin .assert_called_once ()
1079
1117
1080
1118
1081
1119
def test_sigint_handler (base_app ) -> None :
You can’t perform that action at this time.
0 commit comments