Skip to content

Commit

Permalink
[tests/conftest.py]: new API runcmd_interactive.
Browse files Browse the repository at this point in the history
Changes:
-- new API runcmd_interactive to execute a command in interactive mode.
Usage: Say in a Test, we want to run "config save" and want to pass
confirmation later.

Signed-off-by: Praveen Chaudhary <pchaudhary@linkedin.com>
  • Loading branch information
Praveen committed Mar 4, 2021
1 parent 721f47d commit 11f01f7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,19 @@ def runcmd(self, cmd: str) -> Tuple[int, str]:

return (exitcode, out)

def runcmd_interactive(self, cmd):
res = self.ctn.exec_run(cmd, socket=True, stdout=True, stdin=True, tty=True)
try:
exitcode = res.exit_code
out = res.output
except AttributeError:
exitcode = None
out = res
if exitcode is not None:
print "-----rc={} for cmd {}-----".format(exitcode, cmd)

return (exitcode, out)

# used in buildimage tests, do not delete
def copy_file(self, path: str, filename: str) -> None:
tarstr = io.BytesIO()
Expand Down

0 comments on commit 11f01f7

Please sign in to comment.