Skip to content

Commit 7490c3b

Browse files
Nic Watsonjonathanslenders
authored andcommitted
Remove no-\r assertion in print_formatted_text
1 parent 74ef692 commit 7490c3b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

prompt_toolkit/renderer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,11 @@ def print_formatted_text(
679679
else:
680680
output.reset_attributes()
681681

682+
# Eliminate carriage returns
683+
text = text.replace('\r', '')
684+
682685
# Assume that the output is raw, and insert a carriage return before
683686
# every newline. (Also important when the front-end is a telnet client.)
684-
assert '\r' not in text
685687
output.write(text.replace('\n', '\r\n'))
686688

687689
# Reset again.

tests/test_print_formatted_text.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def test_print_formatted_text():
4848
assert b'hello' in f.data
4949
assert b'world' in f.data
5050

51+
@pytest.mark.skipif(
52+
is_windows(), reason="Doesn't run on Windows yet.")
53+
def test_print_formatted_text_backslash_r():
54+
f = _Capture()
55+
pt_print('hello\r\n', file=f)
56+
assert b'hello' in f.data
5157

5258
@pytest.mark.skipif(
5359
is_windows(), reason="Doesn't run on Windows yet.")

0 commit comments

Comments
 (0)