def test_fetchmany(self):
        with self.connect() as connection:
            with connection.cursor() as cursor:
                cursor.execute(
                    '''
                        DECLARE @{0} TABLE(i INT);
                        INSERT INTO @{0}(i) VALUES (1),(2),(3);
                        SELECT * FROM @{0};
                        SELECT i * 2 FROM @{0};
                    '''.format(self.test_fetchmany.__name__)
                )
                self.assertEqual([tuple(row) for row in cursor.fetchmany()], [(1,)])
                self.assertEqual([tuple(row) for row in cursor.fetchmany()], [(2,)])
                self.assertEqual([tuple(row) for row in cursor.fetchmany()], [(3,)])
                self.assertEqual(list(cursor.fetchmany()), [])
                self.assertEqual(cursor.nextset(), True)
                self.assertEqual([tuple(row) for row in cursor.fetchmany()], [(2,)])
                self.assertEqual([tuple(row) for row in cursor.fetchmany()], [(4,)])
                self.assertEqual([tuple(row) for row in cursor.fetchmany()], [(6,)])
                self.assertEqual(list(cursor.fetchmany()), [])
                self.assertEqual(cursor.nextset(), None)
                self.assertRaises(ctds.InterfaceError, cursor.fetchmany)

                cursor.arraysize = 3
                cursor.execute(
                    '''
                        DECLARE @{0} TABLE(i INT);
                        INSERT INTO @{0}(i) VALUES (1),(2),(3);
                        SELECT * FROM @{0};
                        SELECT i * 2 FROM @{0};
                    '''.format(self.test_fetchmany.__name__)
                )
                self.assertEqual([tuple(row) for row in cursor.fetchmany(3)], [(1,), (2,), (3,)])
                self.assertEqual(list(cursor.fetchmany()), [])
                self.assertEqual(cursor.nextset(), True)
                self.assertEqual([tuple(row) for row in cursor.fetchmany(3)], [(2,), (4,), (6,)])
                self.assertEqual(list(cursor.fetchmany()), [])
                self.assertEqual(cursor.nextset(), None)
                self.assertRaises(ctds.InterfaceError, cursor.fetchmany)