From 02fe785cfe7f6a3978971307a2480e74479a59cc Mon Sep 17 00:00:00 2001 From: Dimitry Sibiryakov Date: Sat, 10 Aug 2024 13:09:26 +0200 Subject: [PATCH] Add checks for errors' conditions --- tests/bugs/gh_7057_test.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/bugs/gh_7057_test.py b/tests/bugs/gh_7057_test.py index 80f1600b..4737f62c 100644 --- a/tests/bugs/gh_7057_test.py +++ b/tests/bugs/gh_7057_test.py @@ -98,11 +98,26 @@ def test_1(act: Action, capsys): con.commit() cur = con.cursor() - cur.open('select id from ts') + cur.open('select id from ts for update') + cur.set_cursor_name('X') for row in cur: print_row(row) +# Check for error states: +# Cursor is not positioned on valid record + try: + con.execute_immediate('update ts set id = -id where current of X') + except Exception as err: + print(err) +# Cursor is closed + cur.close() + try: + con.execute_immediate('update ts set id = -id where current of X') + except Exception as err: + print(err) + con.commit() + act.stdout = capsys.readouterr().out act.expected_stdout = """ 1 @@ -148,5 +163,11 @@ def test_1(act: Action, capsys): 8 9 -10 + Dynamic SQL Error + -Cursor X is not positioned in a valid record + Dynamic SQL Error + -SQL error code = -504 + -Invalid cursor reference + -Cursor X is not found in the current context """ assert act.clean_stdout == act.clean_expected_stdout