Add tests for nextset

This commit is contained in:
INADA Naoki
2013-09-27 09:47:40 +09:00
parent 29db7faba4
commit 6b46bb4d5b
2 changed files with 29 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
from pymysql.tests.test_issues import * from pymysql.tests.test_issues import *
from pymysql.tests.test_basic import * from pymysql.tests.test_basic import *
from pymysql.tests.test_nextset import *
from pymysql.tests.test_DictCursor import * from pymysql.tests.test_DictCursor import *
from pymysql.tests.test_connection import TestConnection from pymysql.tests.test_connection import TestConnection

View File

@@ -0,0 +1,28 @@
from pymysql.tests import base
from pymysql import util
class TestNextset(base.PyMySQLTestCase):
def setUp(self):
super(TestNextset, self).setUp()
self.con = self.connections[0]
def test_nextset(self):
cur = self.con.cursor()
cur.execute("SELECT 1; SELECT 2;")
self.assertEqual([(1,)], list(cur))
r = cur.nextset()
self.assertTrue(r)
self.assertEqual([(2,)], list(cur))
self.assertIsNone(cur.nextset())
def test_skip_nextset(self):
cur = self.con.cursor()
cur.execute("SELECT 1; SELECT 2;")
self.assertEqual([(1,)], list(cur))
cur.execute("SELECT 42")
self.assertEqual([(42,)], list(cur))