Skip to content

Commit

Permalink
ls was not found on GH runner. use a different program to test stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
aerorahul committed Mar 23, 2024
1 parent 189c2e3 commit ef94324
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit ef94324

Please sign in to comment.