mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 10:01:46 +04:00
Revert "Change cmd_output_bs retcode arg to a boolean check"
This commit is contained in:
parent
0827de1864
commit
19710cd956
17 changed files with 37 additions and 33 deletions
|
|
@ -18,10 +18,11 @@ from pre_commit.util import tmpdir
|
|||
|
||||
|
||||
def test_CalledProcessError_str():
|
||||
error = CalledProcessError(1, ('exe',), b'output', b'errors')
|
||||
error = CalledProcessError(1, ('exe',), 0, b'output', b'errors')
|
||||
assert str(error) == (
|
||||
"command: ('exe',)\n"
|
||||
'return code: 1\n'
|
||||
'expected return code: 0\n'
|
||||
'stdout:\n'
|
||||
' output\n'
|
||||
'stderr:\n'
|
||||
|
|
@ -30,10 +31,11 @@ def test_CalledProcessError_str():
|
|||
|
||||
|
||||
def test_CalledProcessError_str_nooutput():
|
||||
error = CalledProcessError(1, ('exe',), b'', b'')
|
||||
error = CalledProcessError(1, ('exe',), 0, b'', b'')
|
||||
assert str(error) == (
|
||||
"command: ('exe',)\n"
|
||||
'return code: 1\n'
|
||||
'expected return code: 0\n'
|
||||
'stdout: (none)\n'
|
||||
'stderr: (none)'
|
||||
)
|
||||
|
|
@ -81,14 +83,14 @@ def test_tmpdir():
|
|||
|
||||
|
||||
def test_cmd_output_exe_not_found():
|
||||
ret, out, _ = cmd_output('dne', check=False)
|
||||
ret, out, _ = cmd_output('dne', retcode=None)
|
||||
assert ret == 1
|
||||
assert out == 'Executable `dne` not found'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fn', (cmd_output_b, cmd_output_p))
|
||||
def test_cmd_output_exe_not_found_bytes(fn):
|
||||
ret, out, _ = fn('dne', check=False, stderr=subprocess.STDOUT)
|
||||
ret, out, _ = fn('dne', retcode=None, stderr=subprocess.STDOUT)
|
||||
assert ret == 1
|
||||
assert out == b'Executable `dne` not found'
|
||||
|
||||
|
|
@ -99,7 +101,7 @@ def test_cmd_output_no_shebang(tmpdir, fn):
|
|||
make_executable(f)
|
||||
|
||||
# previously this raised `OSError` -- the output is platform specific
|
||||
ret, out, _ = fn(str(f), check=False, stderr=subprocess.STDOUT)
|
||||
ret, out, _ = fn(str(f), retcode=None, stderr=subprocess.STDOUT)
|
||||
assert ret == 1
|
||||
assert isinstance(out, bytes)
|
||||
assert out.endswith(b'\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue