diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-15 06:46:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-15 06:46:32 +0000 |
commit | 570030879001869cc11575fc1869176719aa99f8 (patch) | |
tree | 1f2c4f2fd1864ef6bcd85da10c4c7dfac8f8b217 /tests/utils.py | |
parent | Releasing debian version 1.12.3-1. (diff) | |
download | litecli-570030879001869cc11575fc1869176719aa99f8.tar.xz litecli-570030879001869cc11575fc1869176719aa99f8.zip |
Merging upstream version 1.12.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py index 4bacc94..79d59e6 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -88,3 +88,27 @@ def send_ctrl_c(wait_seconds): ctrl_c_process = multiprocessing.Process(target=send_ctrl_c_to_pid, args=(os.getpid(), wait_seconds)) ctrl_c_process.start() return ctrl_c_process + + +def assert_result_equal( + result, + title=None, + rows=None, + headers=None, + status=None, + auto_status=True, + assert_contains=False, +): + """Assert that an sqlexecute.run() result matches the expected values.""" + if status is None and auto_status and rows: + status = "{} row{} in set".format(len(rows), "s" if len(rows) > 1 else "") + fields = {"title": title, "rows": rows, "headers": headers, "status": status} + + if assert_contains: + # Do a loose match on the results using the *in* operator. + for key, field in fields.items(): + if field: + assert field in result[0][key] + else: + # Do an exact match on the fields. + assert result == [fields] |