Skip to content

Commit 96ab4e8

Browse files
committed
Add regression test for _insert_plain_text() carriage return handling
Add regression to test for #272
1 parent ed4ddc8 commit 96ab4e8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

qtconsole/tests/test_00_console_widget.py

+21
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,27 @@ def test_erase_in_line(self):
371371
# clear all the text
372372
cursor.insertText('')
373373

374+
def test_carriage_return(self):
375+
""" Does overwriting the currentt line with carriage return work?
376+
"""
377+
w = ConsoleWidget()
378+
test_inputs = ['Hello\n'
379+
'World\r',
380+
'*' * 10,
381+
'\r'
382+
'0', '1', '2', '3', '4',
383+
'5', '6', '7', '8', '9',
384+
'\r\n']
385+
386+
expected_output = "Hello\u20290123456789\u2029"
387+
388+
for text in test_inputs:
389+
cursor = w._get_cursor()
390+
w._insert_plain_text(cursor, text, flush = True)
391+
w._flush_pending_stream() # emulate text being flushed
392+
393+
self.assert_text_equal(cursor, expected_output)
394+
374395
def test_link_handling(self):
375396
noButton = QtCore.Qt.NoButton
376397
noButtons = QtCore.Qt.NoButton

0 commit comments

Comments
 (0)