From e344f2d2c982e0e044bf001c389725ea964b3b93 Mon Sep 17 00:00:00 2001 From: Dan Boitnott Date: Mon, 7 Oct 2024 18:58:29 -0500 Subject: [PATCH] [Resolve #1520] Replace hard-coded shell paths (#1523) Replaced hard-coded shell paths in some unit tests. --- tests/test_hooks/test_cmd.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_hooks/test_cmd.py b/tests/test_hooks/test_cmd.py index 4dfa24c4b..9686f5f67 100644 --- a/tests/test_hooks/test_cmd.py +++ b/tests/test_hooks/test_cmd.py @@ -147,14 +147,21 @@ def test_hook_writes_to_stderr(stack, capfd): def test_default_shell_is_sh(stack, capfd): Cmd("echo $0", stack).run() cap = capfd.readouterr() - assert cap.out.strip() == "/bin/sh" + assert cap.out.strip().split("/")[-2:] == ["bin", "sh"] assert cap.err.strip() == "" def test_shell_parameter_sets_the_shell(stack, capfd): - Cmd({"run": "echo $0", "shell": "/bin/bash"}, stack).run() + # Determine the local path to bash (it's not always /bin/bash) + Cmd("echo $0", stack).run() + cap = capfd.readouterr() + assert cap.err.strip() == "" + bash = cap.out.strip() + + # Confirm the correct shell is used in the sub-process + Cmd({"run": "echo $0", "shell": bash}, stack).run() cap = capfd.readouterr() - assert cap.out.strip() == "/bin/bash" + assert cap.out.strip() == bash assert cap.err.strip() == ""