Skip to content

Commit

Permalink
tests: Check exit code of command
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Nov 25, 2024
1 parent 566ab40 commit 9a007ea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/unit/channel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ def ssh_channel(ssh_client_session):
@pytest.mark.forked
def exec_second_command(ssh_channel):
"""Check the standard output of ``exec_command()`` as a string."""
u_cmd_out = ssh_channel.exec_command('echo -n Hello Again').stdout.decode()
assert u_cmd_out == u'Hello Again' # noqa: WPS302
u_cmd = ssh_channel.exec_command('echo -n Hello Again')
assert u_cmd.returncode == 0
assert u_cmd.stdout.decode() == u'Hello Again' # noqa: WPS302


def test_exec_command(ssh_channel):
"""Test getting the output of a remotely executed command."""
u_cmd_out = ssh_channel.exec_command('echo -n Hello World').stdout.decode()
assert u_cmd_out == u'Hello World' # noqa: WPS302
u_cmd = ssh_channel.exec_command('echo -n Hello World')
assert u_cmd.returncode == 0
assert u_cmd.stdout.decode() == u'Hello World' # noqa: WPS302
# Test that repeated calls to exec_command do not segfault.

# NOTE: Call `exec_command()` once again from another function to
Expand Down

0 comments on commit 9a007ea

Please sign in to comment.