Skip to content

Commit 7507647

Browse files
committed
[DB-12019] cursor test only fails on >2.1
1 parent 6021c78 commit 7507647

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

tests/nuodb_cursor_test.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from .nuodb_base import NuoBase
66
from pynuodb.exception import DataError, ProgrammingError, BatchError, OperationalError
7+
from distutils.version import LooseVersion
8+
from os import getenv
79

810

911
class NuoDBCursorTest(NuoBase):
@@ -126,26 +128,27 @@ def test_executemany_somefail(self):
126128
cursor.execute("DROP TABLE executemany_table")
127129

128130
def test_result_set_gets_closed(self):
131+
current_version = getenv('NUODB_VERSION', None) # skipif <2.1
132+
if current_version is not None and LooseVersion(current_version) < LooseVersion("2.1"):
129133
# 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:
134+
con = self._connect()
135+
for j in [False, True]:
136+
for i in range(2015):
137+
if not j:
146138
cursor = con.cursor()
147139
cursor.execute('select 1 from dual;')
148140
con.commit()
141+
cursor.close()
142+
else:
143+
if i >= 1000:
144+
with self.assertRaises(OperationalError):
145+
cursor = con.cursor()
146+
cursor.execute('select 1 from dual;')
147+
con.commit()
148+
else:
149+
cursor = con.cursor()
150+
cursor.execute('select 1 from dual;')
151+
con.commit()
149152

150153

151154
if __name__ == '__main__':

0 commit comments

Comments
 (0)