From 0d05f7f0ce8cb01e068fe38f22cf0e5cc858b996 Mon Sep 17 00:00:00 2001 From: Iain Samuel McLean Elder Date: Fri, 24 Nov 2023 19:22:57 +0000 Subject: [PATCH] [Resolves #1383] Simplify stderr test for cmd hook (#1387) The old test expected `/bin/sh` to write Dash's error message. This works on Ubuntu 20. It old test failed when `/bin/sh` pointed to `/bin/bash`. This happens on macOS. The new test no longer depends on system-defined side effects of a missing command. It just writes to the standard error stream and checks that the same text comes out. --- tests/test_hooks/test_cmd.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_hooks/test_cmd.py b/tests/test_hooks/test_cmd.py index 11d7898a4..4dfa24c4b 100644 --- a/tests/test_hooks/test_cmd.py +++ b/tests/test_hooks/test_cmd.py @@ -138,11 +138,10 @@ def test_hook_writes_to_stdout(stack, capfd): def test_hook_writes_to_stderr(stack, capfd): - with pytest.raises(Exception): - Cmd("missing_command", stack).run() + Cmd("echo hello >&2", stack).run() cap = capfd.readouterr() assert cap.out.strip() == "" - assert cap.err.strip() == "/bin/sh: 1: missing_command: not found" + assert cap.err.strip() == "hello" def test_default_shell_is_sh(stack, capfd):