diff --git a/tests/test_executable.py b/tests/test_executable.py index 2182bb2..03aeed3 100644 --- a/tests/test_executable.py +++ b/tests/test_executable.py @@ -65,19 +65,21 @@ def test_stderr(tmp_path): """ Tests the `stderr` attribute of the `Executable` class """ - cmd = which("ls", required=True) + cmd = which("which", required=True) stdout_file = tmp_path / 'stdout' stderr_file = tmp_path / 'stderr' with pytest.raises(ProcessError): - cmd("--help", output=str(stdout_file), error=str(stderr_file)) + cmd("-h", output=str(stdout_file), error=str(stderr_file)) # Assert there is no stdout with open(str(stdout_file)) as fh: assert fh.read() == '' - # Assert stderr is not empty, '--help' is an unrecognized option + # Assert stderr is not empty, '-h' is a bad option for `which` with open(str(stderr_file)) as fh: stderr = fh.read() assert stderr != '' - print(stderr) + # Depending on the OS, the error message may vary + # This was seen on macOS + # assert stderr == "/usr/bin/which: illegal option -- h" + '\n' + "usage: which [-as] program ..." + '\n'