Skip to content

Commit 9a007ea

Browse files
committed
tests: Check exit code of command
Signed-off-by: Jakub Jelen <[email protected]>
1 parent 566ab40 commit 9a007ea

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: tests/unit/channel_test.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ def ssh_channel(ssh_client_session):
3636
@pytest.mark.forked
3737
def exec_second_command(ssh_channel):
3838
"""Check the standard output of ``exec_command()`` as a string."""
39-
u_cmd_out = ssh_channel.exec_command('echo -n Hello Again').stdout.decode()
40-
assert u_cmd_out == u'Hello Again' # noqa: WPS302
39+
u_cmd = ssh_channel.exec_command('echo -n Hello Again')
40+
assert u_cmd.returncode == 0
41+
assert u_cmd.stdout.decode() == u'Hello Again' # noqa: WPS302
4142

4243

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

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

0 commit comments

Comments
 (0)