@@ -38,6 +38,66 @@ def test_stock_questionary_select_escape_cancels() -> None:
3838 assert app .run () is None
3939
4040
41+ def test_stock_questionary_confirm_escape_cancels () -> None :
42+ """Verify that pressing Escape cancels a confirm prompt (Issue #1117).
43+
44+ Sends the Escape byte (\\ x1b) to a questionary.confirm application
45+ and asserts that it returns None instead of hanging.
46+ """
47+ install_questionary_escape_cancel ()
48+ with create_pipe_input () as pipe_input :
49+ q = questionary .confirm (
50+ "Are you sure?" ,
51+ input = pipe_input ,
52+ output = DummyOutput (),
53+ )
54+ pipe_input .send_bytes (b"\x1b " )
55+ app = q .application
56+ app .input = pipe_input
57+ app .output = DummyOutput ()
58+ assert app .run () is None
59+
60+
61+ def test_stock_questionary_text_escape_cancels () -> None :
62+ """Verify that pressing Escape cancels a text input prompt (Issue #1117).
63+
64+ Sends the Escape byte (\\ x1b) to a questionary.text application
65+ and asserts that it returns None.
66+ """
67+ install_questionary_escape_cancel ()
68+ with create_pipe_input () as pipe_input :
69+ q = questionary .text (
70+ "Name" ,
71+ input = pipe_input ,
72+ output = DummyOutput (),
73+ )
74+ pipe_input .send_bytes (b"\x1b " )
75+ app = q .application
76+ app .input = pipe_input
77+ app .output = DummyOutput ()
78+ assert app .run () is None
79+
80+
81+ def test_stock_questionary_path_escape_cancels () -> None :
82+ """Verify that pressing Escape cancels a path selection prompt (Issue #1117).
83+
84+ Sends the Escape byte (\\ x1b) to a questionary.path application
85+ and asserts that it returns None.
86+ """
87+ install_questionary_escape_cancel ()
88+ with create_pipe_input () as pipe_input :
89+ q = questionary .path (
90+ "Path" ,
91+ input = pipe_input ,
92+ output = DummyOutput (),
93+ )
94+ pipe_input .send_bytes (b"\x1b " )
95+ app = q .application
96+ app .input = pipe_input
97+ app .output = DummyOutput ()
98+ assert app .run () is None
99+
100+
41101def test_install_questionary_ctrl_c_double_exit_is_idempotent () -> None :
42102 install_questionary_ctrl_c_double_exit ()
43103 first = questionary .select
0 commit comments