Skip to content

Commit d7cb7ca

Browse files
committed
Add missing yield
1 parent d3ca6c4 commit d7cb7ca

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

tornado_mysql/tests/test_SSCursor.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ def test_SSCursor(self):
9494
'executemany failed. cursor.rowcount != %s' % (str(len(self.data))))
9595

9696
# Test multiple datasets
97-
cursor.execute('SELECT 1; SELECT 2; SELECT 3')
97+
yield cursor.execute('SELECT 1; SELECT 2; SELECT 3')
9898
self.assertListEqual(list(cursor), [(1, )])
99-
self.assertTrue(cursor.nextset())
99+
res = yield cursor.nextset()
100+
self.assertTrue(res)
100101
self.assertListEqual(list(cursor), [(2, )])
101-
self.assertTrue(cursor.nextset())
102+
res = yield cursor.nextset()
103+
self.assertTrue(res)
102104
self.assertListEqual(list(cursor), [(3, )])
103-
self.assertFalse(cursor.nextset())
104-
105+
res = yield cursor.nextset()
106+
self.assertFalse(res)
105107
finally:
106108
yield cursor.execute('DROP TABLE tz_data')
107109
yield cursor.close()
@@ -126,6 +128,7 @@ def _cleanup(self):
126128
conn = self.connections[0]
127129
cursor = conn.cursor()
128130
yield cursor.execute('DROP TABLE IF EXISTS tz_data;')
131+
yield cursor.close()
129132

130133
@gen_test
131134
def test_sscursor_executemany(self):
@@ -135,6 +138,7 @@ def test_sscursor_executemany(self):
135138
# Test executemany
136139
yield cursor.executemany(
137140
'INSERT INTO tz_data VALUES (%s, %s, %s)', self.data)
141+
yield cursor._close()
138142
msg = 'executemany failed. cursor.rowcount != %s'
139143
self.assertEqual(cursor.rowcount, len(self.data),
140144
msg % (str(len(self.data))))

tornado_mysql/tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_datatypes(self):
5454
r = c.fetchall()
5555
self.assertEqual(((4,),(8,)), r)
5656
finally:
57-
c.execute("drop table test_datatypes")
57+
yield c.execute("drop table test_datatypes")
5858

5959
@gen_test
6060
def test_dict(self):

tornado_mysql/tests/test_issues.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
import unittest
3+
import warnings
34

45
try:
56
import imp
@@ -271,13 +272,15 @@ def disabled_test_issue_54(self):
271272
class TestGitHubIssues(base.PyMySQLTestCase):
272273
@gen_test
273274
def test_issue_66(self):
274-
""" 'Connection' object has no attribute 'insert_id' """
275+
"""'Connection' object has no attribute 'insert_id'"""
275276
conn = self.connections[0]
276277
c = conn.cursor()
277278
self.assertEqual(0, conn.insert_id())
278-
try:
279+
with warnings.catch_warnings():
280+
warnings.simplefilter("ignore")
279281
yield c.execute("drop table if exists issue66")
280-
yield c.execute("create table issue66 (id integer primary key auto_increment, x integer)")
282+
yield c.execute("create table issue66 (id integer primary key auto_increment, x integer)")
283+
try:
281284
yield c.execute("insert into issue66 (x) values (1)")
282285
yield c.execute("insert into issue66 (x) values (1)")
283286
self.assertEqual(2, conn.insert_id())
@@ -290,8 +293,10 @@ def test_issue_79(self):
290293
conn = self.connections[0]
291294
c = conn.cursor(tornado_mysql.cursors.DictCursor)
292295

293-
yield c.execute("drop table if exists a")
294-
yield c.execute("drop table if exists b")
296+
with warnings.catch_warnings():
297+
warnings.simplefilter("ignore")
298+
yield c.execute("drop table if exists a")
299+
yield c.execute("drop table if exists b")
295300
yield c.execute("""CREATE TABLE a (id int, value int)""")
296301
yield c.execute("""CREATE TABLE b (id int, value int)""")
297302

0 commit comments

Comments
 (0)