File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 55from pathlib import Path
66
77from prompt_toolkit .key_binding import KeyBindings , KeyPressEvent
8+ from prompt_toolkit .keys import Keys
89
910from commitizen import git
1011from commitizen .cz import exceptions
1617def get_multiline_key_bindings () -> KeyBindings :
1718 kb = KeyBindings ()
1819
19- @kb .add ("enter" )
20+ @kb .add (Keys . Enter )
2021 def handle_enter (event : KeyPressEvent ) -> None :
2122 buff = event .app .current_buffer
2223 if buff .text == "" :
Original file line number Diff line number Diff line change 11import pytest
2+ from prompt_toolkit .keys import Keys
23from pytest_mock import MockFixture
34
45from commitizen .cz import exceptions , utils
56
67
78def test_multiline_key_bindings_enter_submits_on_empty (mocker : MockFixture ):
89 kb = utils .get_multiline_key_bindings ()
9- handler = kb . get_bindings_for_keys (( "enter" ,))[ 0 ] .handler
10+ handler = next ( b .handler for b in kb . bindings if Keys . Enter in b . keys )
1011
1112 buff = mocker .MagicMock ()
1213 buff .text = ""
@@ -20,7 +21,7 @@ def test_multiline_key_bindings_enter_submits_on_empty(mocker: MockFixture):
2021
2122def test_multiline_key_bindings_enter_inserts_newline (mocker : MockFixture ):
2223 kb = utils .get_multiline_key_bindings ()
23- handler = kb . get_bindings_for_keys (( "enter" ,))[ 0 ] .handler
24+ handler = next ( b .handler for b in kb . bindings if Keys . Enter in b . keys )
2425
2526 buff = mocker .MagicMock ()
2627 buff .text = "some content"
You can’t perform that action at this time.
0 commit comments