WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 6206834

Browse files
committed
to handle the clear command, need to have the TERM variable set
1 parent ba6e3be commit 6206834

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

interactive_process/interactive_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ReadWriteError(Exception):
1010

1111

1212
class InteractiveProcess:
13-
def __init__(self, env={"PS1": ""}, echo=False):
13+
def __init__(self, env={"PS1": "", "TERM": "xterm"}, echo=False):
1414
if platform.system() == 'Windows':
1515
shell = 'cmd.exe'
1616
else:

tests/test_interactive_process.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,10 @@ def test_read_nonblocking_read_error(self):
9191
self.process.send_command("echo Hello")
9292
with pytest.raises(ReadWriteError, match="Failed to read due to OSError") as exc:
9393
self.process.read_nonblocking()
94+
95+
96+
def test_read_nonblocking_clear_command(self):
97+
self.process.send_command('clear && echo Completed 4e556f02-38a1-4eec-8e0c-2d8afcd37ae7')
98+
time.sleep(1)
99+
value = self.process.read_nonblocking(1)
100+
assert value.strip() == "\x1b[3J\x1b[H\x1b[2JCompleted 4e556f02-38a1-4eec-8e0c-2d8afcd37ae7"

0 commit comments

Comments
 (0)