fix(keyringctl): fix system stderr case due to wrongly written test
CalledProcessError returns bytes for our invocations, the fix that decoded bytes of stdout was purely to make the mocked test happy while breaking the actual usage. Restore the behavior and fix the wrong mocked data.
This commit is contained in:
parent
cd585f4be2
commit
279765b22a
@ -115,7 +115,7 @@ def system(
|
|||||||
try:
|
try:
|
||||||
return check_output(cmd, stderr=STDOUT, stdin=_stdin, env=env).decode()
|
return check_output(cmd, stderr=STDOUT, stdin=_stdin, env=env).decode()
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
stderr.buffer.write(bytes(e.stdout, encoding="utf8"))
|
stderr.buffer.write(e.stdout)
|
||||||
print_stack()
|
print_stack()
|
||||||
if exit_on_error:
|
if exit_on_error:
|
||||||
exit(e.returncode)
|
exit(e.returncode)
|
||||||
|
@ -50,7 +50,7 @@ def test_natural_sort_path(input_list: List[Path], output_list: List[Path]) -> N
|
|||||||
@patch("libkeyringctl.util.check_output")
|
@patch("libkeyringctl.util.check_output")
|
||||||
def test_system(check_output_mock: Mock, exit_mock: Mock, raise_on_cmd: bool, exit_on_error: bool) -> None:
|
def test_system(check_output_mock: Mock, exit_mock: Mock, raise_on_cmd: bool, exit_on_error: bool) -> None:
|
||||||
if raise_on_cmd:
|
if raise_on_cmd:
|
||||||
check_output_mock.side_effect = util.CalledProcessError(returncode=1, cmd="foo", output="output")
|
check_output_mock.side_effect = util.CalledProcessError(returncode=1, cmd="foo", output=b"output")
|
||||||
|
|
||||||
with raises(util.CalledProcessError):
|
with raises(util.CalledProcessError):
|
||||||
util.system(["foo"], exit_on_error=exit_on_error)
|
util.system(["foo"], exit_on_error=exit_on_error)
|
||||||
|
Loading…
Reference in New Issue
Block a user