@@ -456,6 +456,47 @@ def test_setpos_from_xy_for_non_printing_char(self):
456456 reader .setpos_from_xy (8 , 0 )
457457 self .assertEqual (reader .pos , 7 )
458458
459+
460+ @force_not_colorized_test_class
461+ class TestErrorMessages (TestCase ):
462+ def _test_error_message (
463+ self ,
464+ keys : str ,
465+ expected : str , * ,
466+ command : str | None = None ,
467+ ):
468+ console = prepare_console (code_to_events (keys ))
469+ reader = prepare_reader (console )
470+ if command is not None :
471+ reader .bind (keys , command )
472+
473+ while not reader .msg :
474+ reader .handle1 ()
475+
476+ self .assertEqual (reader .msg , f"! { expected } " )
477+ self .assertEqual (reader .screen [- 1 ], f"! { expected } " )
478+ console .beep .assert_called_once ()
479+
480+ def test_invalid_key_message (self ):
481+ self ._test_error_message ("\x1b o" , "no command is bound to this key" )
482+
483+ def test_unimplemented_command_message (self ):
484+ self ._test_error_message (
485+ "x" ,
486+ "command 'missing-command' is not implemented" ,
487+ command = "missing-command" ,
488+ )
489+
490+ def test_nothing_to_yank_message (self ):
491+ self ._test_error_message ("\x19 " , "nothing to yank" )
492+
493+ def test_start_of_history_message (self ):
494+ self ._test_error_message ("\x10 " , "start of history list" )
495+
496+ def test_no_completion_matches_message (self ):
497+ self ._test_error_message ("does_not_exist\t " , "no matches" )
498+
499+
459500@force_colorized_test_class
460501class TestReaderInColor (ScreenEqualMixin , TestCase ):
461502 def test_syntax_highlighting_basic (self ):
0 commit comments