Skip to content

Commit 2bb38dc

Browse files
[BUG FIX] PostgresNode::safe_psql did not respect "expect_error" parameter
1 parent f9ddd04 commit 2bb38dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

testgres/node.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,13 +1059,22 @@ def safe_psql(self, query=None, expect_error=False, **kwargs):
10591059
"""
10601060
assert type(kwargs) == dict # noqa: E721
10611061
assert not ("ignore_errors" in kwargs.keys())
1062+
assert not ("expect_error" in kwargs.keys())
10621063

10631064
# force this setting
10641065
kwargs['ON_ERROR_STOP'] = 1
10651066
try:
10661067
ret, out, err = self._psql(ignore_errors=False, query=query, **kwargs)
10671068
except ExecUtilException as e:
1068-
raise QueryException(e.message, query)
1069+
if not expect_error:
1070+
raise QueryException(e.message, query)
1071+
1072+
if type(e.error) == bytes: # noqa: E721
1073+
return e.error.decode("utf-8") # throw
1074+
1075+
# [2024-12-09] This situation is not expected
1076+
assert False
1077+
return e.error
10691078

10701079
if expect_error:
10711080
assert False, "Exception was expected, but query finished successfully: `{}` ".format(query)

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