Skip to content

Commit 45cfbf7

Browse files
RemoteOperations::exec_command must not raise an exception when 'expect_error' is True (#159)
This commit fixes an issue #159.
1 parent 22c649d commit 45cfbf7

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

testgres/operations/remote_ops.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,26 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
8383

8484
exit_status = process.returncode
8585

86-
if encoding:
87-
result = result.decode(encoding)
88-
error = error.decode(encoding)
89-
90-
if expect_error:
91-
raise Exception(result, error)
86+
assert type(result) == bytes # noqa: E721
87+
assert type(error) == bytes # noqa: E721
9288

9389
if not error:
94-
error_found = 0
90+
error_found = False
9591
else:
96-
error = normalize_error(error)
9792
error_found = exit_status != 0 or any(
98-
marker in error for marker in ['error', 'Permission denied', 'fatal', 'No such file or directory']
93+
marker in error for marker in [b'error', b'Permission denied', b'fatal', b'No such file or directory']
9994
)
10095

101-
if not ignore_errors and error_found:
102-
if isinstance(error, bytes):
103-
message = b"Utility exited with non-zero code. Error: " + error
104-
else:
105-
message = f"Utility exited with non-zero code. Error: {error}"
96+
assert type(error_found) == bool # noqa: E721
97+
98+
if encoding:
99+
result = result.decode(encoding)
100+
error = error.decode(encoding)
101+
102+
if not ignore_errors and error_found and not expect_error:
103+
error = normalize_error(error)
104+
assert type(error) == str # noqa: E721
105+
message = "Utility exited with non-zero code. Error: " + error
106106
raise ExecUtilException(message=message, command=cmd, exit_code=exit_status, out=result)
107107

108108
if verbose:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy