1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

riotctrl_shell.tests: add capability to access history of commands

This commit is contained in:
Martine Lenders 2021-03-02 09:28:13 +01:00
parent bf93d85d4e
commit ae14386736
No known key found for this signature in database
GPG Key ID: CCD317364F63286F

View File

@ -10,17 +10,25 @@ import contextlib
class MockSpawn():
def __init__(self, ctrl, *args, **kwargs):
self.ctrl = ctrl
self.last_command = None
self.commands = []
# set some expected attributes
self.before = None
self.echo = False
@property
def last_command(self):
if self.commands:
return self.commands[-1]
else:
return None
def read_nonblocking(self, size=1, timeout=-1):
# do nothing, only used to flush pexpect output
pass
def sendline(self, line, *args, **kwargs):
self.last_command = line
if line:
self.commands.append(line)
if self.ctrl.output is None:
# just echo last input for before (what replwrap is assembling
# output from)