1616
1717setup_test_environment ()
1818
19+ from clitt .core .exception .exceptions import NotATerminalError
1920from clitt .core .term .screen import Screen
2021from clitt .core .term .terminal import Terminal
2122from hspylib .modules .application .exit_status import ExitStatus
2425class TestTerminalAttributes (unittest .TestCase ):
2526 @patch .object (Terminal , "is_a_tty" , return_value = False )
2627 def test_set_enable_echo_should_guard_when_not_tty (self , mock_is_tty ):
27- with patch ("clitt.core.term.terminal.os.popen" ) as mock_popen :
28+ with patch ("clitt.core.term.terminal.os.popen" ) as mock_popen , \
29+ patch ("clitt.core.term.terminal.log.warning" ) as mock_warning :
2830 Terminal .set_enable_echo (True )
2931
3032 mock_is_tty .assert_called_once ()
3133 mock_popen .assert_not_called ()
34+ mock_warning .assert_called_once ()
35+ warning_arg = mock_warning .call_args .args [0 ]
36+ self .assertIsInstance (warning_arg , NotATerminalError )
37+ self .assertIn ("set_enable_echo:: Requires a terminal (TTY)" , str (warning_arg ))
3238
3339 @patch .object (Terminal , "is_a_tty" , return_value = True )
3440 def test_set_enable_echo_should_invoke_stty_when_tty (self , mock_is_tty ):
@@ -42,11 +48,16 @@ def test_set_enable_echo_should_invoke_stty_when_tty(self, mock_is_tty):
4248
4349 @patch .object (Terminal , "is_a_tty" , return_value = False )
4450 def test_set_auto_wrap_should_guard_when_not_tty (self , mock_is_tty ):
45- with patch ("clitt.core.term.terminal.sysout" ) as mock_sysout :
51+ with patch ("clitt.core.term.terminal.sysout" ) as mock_sysout , \
52+ patch ("clitt.core.term.terminal.log.warning" ) as mock_warning :
4653 Terminal .set_auto_wrap (True )
4754
4855 mock_is_tty .assert_called_once ()
4956 mock_sysout .assert_not_called ()
57+ mock_warning .assert_called_once ()
58+ warning_arg = mock_warning .call_args .args [0 ]
59+ self .assertIsInstance (warning_arg , NotATerminalError )
60+ self .assertIn ("set_auto_wrap:: Requires a terminal (TTY)" , str (warning_arg ))
5061
5162 @patch .object (Terminal , "is_a_tty" , return_value = True )
5263 def test_set_auto_wrap_should_emit_escape_sequence_when_tty (self , mock_is_tty ):
@@ -60,11 +71,16 @@ def test_set_auto_wrap_should_emit_escape_sequence_when_tty(self, mock_is_tty):
6071
6172 @patch .object (Terminal , "is_a_tty" , return_value = False )
6273 def test_set_show_cursor_should_guard_when_not_tty (self , mock_is_tty ):
63- with patch ("clitt.core.term.terminal.sysout" ) as mock_sysout :
74+ with patch ("clitt.core.term.terminal.sysout" ) as mock_sysout , \
75+ patch ("clitt.core.term.terminal.log.warning" ) as mock_warning :
6476 Terminal .set_show_cursor (True )
6577
6678 mock_is_tty .assert_called_once ()
6779 mock_sysout .assert_not_called ()
80+ mock_warning .assert_called_once ()
81+ warning_arg = mock_warning .call_args .args [0 ]
82+ self .assertIsInstance (warning_arg , NotATerminalError )
83+ self .assertIn ("set_show_cursor:: Requires a terminal (TTY)" , str (warning_arg ))
6884
6985 @patch .object (Terminal , "is_a_tty" , return_value = True )
7086 def test_set_show_cursor_should_emit_escape_sequence_when_tty (self , mock_is_tty ):
0 commit comments