Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Proposal to fix #154 (v2) #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[BUG FIX] PostgresNode::safe_psql did not respect "expect_error" para…
…meter
  • Loading branch information
dmitry-lipetsk committed Dec 9, 2024
commit 2bb38dc45b69c4d5d4c93a65fea4b64b81511287
11 changes: 10 additions & 1 deletion testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,13 +1059,22 @@ def safe_psql(self, query=None, expect_error=False, **kwargs):
"""
assert type(kwargs) == dict # noqa: E721
assert not ("ignore_errors" in kwargs.keys())
assert not ("expect_error" in kwargs.keys())

# force this setting
kwargs['ON_ERROR_STOP'] = 1
try:
ret, out, err = self._psql(ignore_errors=False, query=query, **kwargs)
except ExecUtilException as e:
raise QueryException(e.message, query)
if not expect_error:
raise QueryException(e.message, query)

if type(e.error) == bytes: # noqa: E721
return e.error.decode("utf-8") # throw

# [2024-12-09] This situation is not expected
assert False
return e.error

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