Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb51663c

Browse files
test last_word, add failing test case that caused crash
1 parent3332f4f commitb51663c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

‎bpython/curtsiesfrontend/repl.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,8 @@ def process_key_event(self, e):
628628

629629
defget_last_word(self):
630630

631-
deflast_word(line):
632-
returnline.split().pop()iflineelse''
633-
634-
previous_word=last_word(self.rl_history.entry)
635-
word=last_word(self.rl_history.back())
631+
previous_word=_last_word(self.rl_history.entry)
632+
word=_last_word(self.rl_history.back())
636633
line=self.current_line
637634
self._set_current_line(line[:len(line)-len(previous_word)]+word,
638635
reset_rl_history=False)
@@ -1522,6 +1519,10 @@ def tabs_to_spaces(line):
15221519
returnline.replace('\t',' ')
15231520

15241521

1522+
def_last_word(line):
1523+
returnline.split().pop()iflineelse''
1524+
1525+
15251526
defcompress_paste_event(paste_event):
15261527
"""If all events in a paste event are identical and not simple characters,
15271528
returns one of them

‎bpython/test/test_curtsies_repl.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def test_get_last_word(self):
7777
self.repl.get_last_word()
7878
self.assertEqual(self.repl.current_line,'abcde3')
7979

80+
deftest_last_word(self):
81+
self.assertEquals(curtsiesrepl._last_word(''),'')
82+
self.assertEquals(curtsiesrepl._last_word(' '),'')
83+
self.assertEquals(curtsiesrepl._last_word('a'),'a')
84+
self.assertEquals(curtsiesrepl._last_word('a b'),'b')
85+
8086
# this is the behavior of bash - not currently implemented
8187
@unittest.skip
8288
deftest_get_last_word_with_prev_line(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp