Skip to content

Commit

Permalink
In python3 next has been renamed to __next__ (#17)
Browse files Browse the repository at this point in the history
* In python3 next has been renamed to __next__

https://www.python.org/dev/peps/pep-3114/

* added test for cursor iterator next
  • Loading branch information
basbloemsaat authored and gijzelaerr committed Jan 20, 2017
1 parent f97ff25 commit 1e0c609
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pymonetdb/sql/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ def next(self):
raise StopIteration
return row

def __next__(self):
return self.next()

def __store_result(self, block):
""" parses the mapi result into a resultset"""

Expand Down
22 changes: 22 additions & 0 deletions test/test_dbapi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,28 @@ def _populate(self):
]
return populate



def test_cursor_next(self):
con = self._connect()
try:
cur = con.cursor()

self.executeDDL1(cur)
for sql in self._populate():
cur.execute(sql)

cur.execute('select name from %sbooze' % self.table_prefix)

for row in cur:
pass

except TypeError:
self.fail("Cursor iterator not implemented correctly")

finally:
con.close()

def test_fetchmany(self):
con = self._connect()
try:
Expand Down

0 comments on commit 1e0c609

Please sign in to comment.