Skip to content

Commit 1e0c609

Browse files
basbloemsaatgijzelaerr
authored andcommitted
In python3 next has been renamed to __next__ (#17)
* In python3 next has been renamed to __next__ https://www.python.org/dev/peps/pep-3114/ * added test for cursor iterator next
1 parent f97ff25 commit 1e0c609

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pymonetdb/sql/cursors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ def next(self):
320320
raise StopIteration
321321
return row
322322

323+
def __next__(self):
324+
return self.next()
325+
323326
def __store_result(self, block):
324327
""" parses the mapi result into a resultset"""
325328

test/test_dbapi2.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,28 @@ def _populate(self):
570570
]
571571
return populate
572572

573+
574+
575+
def test_cursor_next(self):
576+
con = self._connect()
577+
try:
578+
cur = con.cursor()
579+
580+
self.executeDDL1(cur)
581+
for sql in self._populate():
582+
cur.execute(sql)
583+
584+
cur.execute('select name from %sbooze' % self.table_prefix)
585+
586+
for row in cur:
587+
pass
588+
589+
except TypeError:
590+
self.fail("Cursor iterator not implemented correctly")
591+
592+
finally:
593+
con.close()
594+
573595
def test_fetchmany(self):
574596
con = self._connect()
575597
try:

0 commit comments

Comments
 (0)