Skip to content

Commit 812d7ee

Browse files
fix tests to deal with kill functions
1 parent 6b8a076 commit 812d7ee

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

bpython/test/test_manual_readline.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ def test_delete_from_cursor_forward(self):
142142
line = "everything after this will be deleted"
143143
pos = line.find("this")
144144
expected = (pos, "everything after ")
145-
result = delete_from_cursor_forward(line.find("this"), line)
145+
result = delete_from_cursor_forward(line.find("this"), line)[:-1]
146146
self.assertEquals(expected, result)
147147

148148
def test_delete_rest_of_word(self):
149-
self.try_stages(['z|s;df asdf d s;a;a',
149+
self.try_stages_kill(['z|s;df asdf d s;a;a',
150150
'z|;df asdf d s;a;a',
151151
'z| asdf d s;a;a',
152152
'z| d s;a;a',
@@ -156,7 +156,7 @@ def test_delete_rest_of_word(self):
156156
'z|'], delete_rest_of_word)
157157

158158
def test_delete_word_to_cursor(self):
159-
self.try_stages([
159+
self.try_stages_kill([
160160
' a;d sdf ;a;s;d; fjksald|a',
161161
' a;d sdf ;a;s;d; |a',
162162
' a;d sdf |a',
@@ -179,6 +179,15 @@ def try_stages(self, strings, func):
179179
for (initial_pos, initial), (final_pos, final) in zip(stages[:-1], stages[1:]):
180180
self.assertEquals(func(initial_pos, initial), (final_pos, final))
181181

182+
def try_stages_kill(self, strings, func):
183+
if not all('|' in s for s in strings):
184+
raise ValueError("Need to use '|' to specify cursor")
185+
186+
stages = [(s.index('|'), s.replace('|', '')) for s in strings]
187+
for (initial_pos, initial), (final_pos, final) in zip(stages[:-1], stages[1:]):
188+
self.assertEquals(func(initial_pos, initial)[:-1], (final_pos, final))
189+
190+
182191
def test_transpose_character_before_cursor(self):
183192
self.try_stages(["as|df asdf",
184193
"ads|f asdf",
@@ -194,7 +203,7 @@ def test_backspace(self):
194203
self.assertEquals(backspace(3, 'as '), (2, 'as'))
195204

196205
def test_delete_word_from_cursor_back(self):
197-
self.try_stages([
206+
self.try_stages_kill([
198207
"asd;fljk asd;lfjas;dlkfj asdlk jasdf;ljk|",
199208
"asd;fljk asd;lfjas;dlkfj asdlk jasdf;|",
200209
"asd;fljk asd;lfjas;dlkfj asdlk |",

0 commit comments

Comments
 (0)