Skip to content

Commit 2fee98f

Browse files
committed
[DB-12019] Test for cursor failing to close resultset
1 parent 9395487 commit 2fee98f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/nuodb_cursor_test.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import unittest
44

55
from .nuodb_base import NuoBase
6-
from pynuodb.exception import DataError, ProgrammingError, BatchError
6+
from pynuodb.exception import DataError, ProgrammingError, BatchError, OperationalError
77

88

99
class NuoDBCursorTest(NuoBase):
@@ -125,6 +125,28 @@ def test_executemany_somefail(self):
125125

126126
cursor.execute("DROP TABLE executemany_table")
127127

128+
def test_result_set_gets_closed(self):
129+
# Server will throw error after 1000 open result sets
130+
con = self._connect()
131+
132+
for j in [False, True]:
133+
for i in range(2015):
134+
if not j:
135+
cursor = con.cursor()
136+
cursor.execute('select 1 from dual;')
137+
con.commit()
138+
cursor.close()
139+
else:
140+
if i >= 1000:
141+
with self.assertRaises(OperationalError):
142+
cursor = con.cursor()
143+
cursor.execute('select 1 from dual;')
144+
con.commit()
145+
else:
146+
cursor = con.cursor()
147+
cursor.execute('select 1 from dual;')
148+
con.commit()
149+
128150

129151
if __name__ == '__main__':
130152
unittest.main()

0 commit comments

Comments
 (0)