Skip to content

Commit

Permalink
Add regression test for _insert_plain_text() carriage return handling
Browse files Browse the repository at this point in the history
Add regression to test for #272
  • Loading branch information
TheMatt2 committed May 28, 2024
1 parent ed4ddc8 commit 96ab4e8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions qtconsole/tests/test_00_console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,27 @@ def test_erase_in_line(self):
# clear all the text
cursor.insertText('')

def test_carriage_return(self):
""" Does overwriting the currentt line with carriage return work?
"""
w = ConsoleWidget()
test_inputs = ['Hello\n'
'World\r',
'*' * 10,
'\r'
'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
'\r\n']

expected_output = "Hello\u20290123456789\u2029"

for text in test_inputs:
cursor = w._get_cursor()
w._insert_plain_text(cursor, text, flush = True)
w._flush_pending_stream() # emulate text being flushed

self.assert_text_equal(cursor, expected_output)

def test_link_handling(self):
noButton = QtCore.Qt.NoButton
noButtons = QtCore.Qt.NoButton
Expand Down

0 comments on commit 96ab4e8

Please sign in to comment.