@@ -32,6 +32,9 @@ def tearDown(self):
3232 c .execute ("drop table dictcursor" )
3333 super (TestDictCursor , self ).tearDown ()
3434
35+ def _ensure_cursor_expired (self , cursor ):
36+ pass
37+
3538 def test_DictCursor (self ):
3639 bob , jim , fred = self .bob .copy (), self .jim .copy (), self .fred .copy ()
3740 #all assert test compare to the structure as would come out from MySQLdb
@@ -45,6 +48,8 @@ def test_DictCursor(self):
4548 c .execute ("SELECT * from dictcursor where name='bob'" )
4649 r = c .fetchone ()
4750 self .assertEqual (bob , r , "fetchone via DictCursor failed" )
51+ self ._ensure_cursor_expired (c )
52+
4853 # same again, but via fetchall => tuple)
4954 c .execute ("SELECT * from dictcursor where name='bob'" )
5055 r = c .fetchall ()
@@ -65,6 +70,7 @@ def test_DictCursor(self):
6570 c .execute ("SELECT * from dictcursor" )
6671 r = c .fetchmany (2 )
6772 self .assertEqual ([bob , jim ], r , "fetchmany failed via DictCursor" )
73+ self ._ensure_cursor_expired (c )
6874
6975 def test_custom_dict (self ):
7076 class MyDict (dict ): pass
@@ -81,6 +87,7 @@ class MyDictCursor(self.cursor_type):
8187 cur .execute ("SELECT * FROM dictcursor WHERE name='bob'" )
8288 r = cur .fetchone ()
8389 self .assertEqual (bob , r , "fetchone() returns MyDictCursor" )
90+ self ._ensure_cursor_expired (cur )
8491
8592 cur .execute ("SELECT * FROM dictcursor" )
8693 r = cur .fetchall ()
@@ -96,11 +103,14 @@ class MyDictCursor(self.cursor_type):
96103 r = cur .fetchmany (2 )
97104 self .assertEqual ([bob , jim ], r ,
98105 "list failed via MyDictCursor" )
106+ self ._ensure_cursor_expired (cur )
99107
100108
101109class TestSSDictCursor (TestDictCursor ):
102110 cursor_type = pymysql .cursors .SSDictCursor
103111
112+ def _ensure_cursor_expired (self , cursor ):
113+ list (cursor .fetchall_unbuffered ())
104114
105115if __name__ == "__main__" :
106116 import unittest
0 commit comments