<s> import warnings <EOL> from pymysql . tests import base <EOL> import pymysql . cursors <EOL> class CursorTest ( base . PyMySQLTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( CursorTest , self ) . setUp ( ) <EOL> conn = self . connections [ <NUM_LIT:0> ] <EOL> self . safe_create_table ( <EOL> conn , <EOL> "<STR_LIT:test>" , "<STR_LIT>" , <EOL> ) <EOL> cursor = conn . cursor ( ) <EOL> cursor . execute ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> cursor . close ( ) <EOL> self . test_connection = pymysql . connect ( ** self . databases [ <NUM_LIT:0> ] ) <EOL> self . addCleanup ( self . test_connection . close ) <EOL> def test_cleanup_rows_unbuffered ( self ) : <EOL> conn = self . test_connection <EOL> cursor = conn . cursor ( pymysql . cursors . SSCursor ) <EOL> cursor . execute ( "<STR_LIT>" ) <EOL> for counter , row in enumerate ( cursor ) : <EOL> if counter > <NUM_LIT:10> : <EOL> break <EOL> del cursor <EOL> self . safe_gc_collect ( ) <EOL> c2 = conn . cursor ( ) <EOL> with warnings . catch_warnings ( record = True ) as log : <EOL> warnings . filterwarnings ( "<STR_LIT>" ) <EOL> c2 . execute ( "<STR_LIT>" ) <EOL> self . assertGreater ( len ( log ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( <EOL> "<STR_LIT>" , <EOL> str ( log [ - <NUM_LIT:1> ] . message ) ) <EOL> self . assertEqual ( <EOL> c2 . fetchone ( ) , ( <NUM_LIT:1> , ) <EOL> ) <EOL> self . assertIsNone ( c2 . fetchone ( ) ) <EOL> def test_cleanup_rows_buffered ( self ) : <EOL> conn = self . test_connection <EOL> cursor = conn . cursor ( pymysql . cursors . Cursor ) <EOL> cursor . execute ( "<STR_LIT>" ) <EOL> for counter , row in enumerate ( cursor ) : <EOL> if counter > <NUM_LIT:10> : <EOL> break <EOL> del cursor <EOL> self . safe_gc_collect ( ) <EOL> c2 = conn . cursor ( ) <EOL> c2 . execute ( "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> c2 . fetchone ( ) , ( <NUM_LIT:1> , ) <EOL> ) <EOL> self . assertIsNone ( c2 . fetchone ( ) ) </s>
