Skip to content

Commit d3ca6c4

Browse files
committed
fix some tests
1 parent 0503973 commit d3ca6c4

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

tornado_mysql/connections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ def close(self):
624624
@gen.coroutine
625625
def close_async(self):
626626
"""Send the quit message and close the socket"""
627-
send_data = struct.pack('<i', 1) + int2byte(COM_QUIT)
627+
send_data = struct.pack('<i', 1) + int2byte(COMMAND.COM_QUIT)
628628
yield self._stream.write(send_data)
629629
self.close()
630630

tornado_mysql/tests/test_DictCursor.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def shutdown():
4141
c.execute("drop table dictcursor")
4242
super(TestDictCursor, self).tearDown()
4343

44+
@gen.coroutine
4445
def _ensure_cursor_expired(self, cursor):
45-
pass
46+
raise gen.Return()
4647

4748
@gen_test
4849
def test_DictCursor(self):
@@ -58,7 +59,7 @@ def test_DictCursor(self):
5859
yield c.execute("SELECT * from dictcursor where name='bob'")
5960
r = c.fetchone()
6061
self.assertEqual(bob, r, "fetchone via DictCursor failed")
61-
self._ensure_cursor_expired(c)
62+
yield self._ensure_cursor_expired(c)
6263

6364
# same again, but via fetchall => tuple)
6465
yield c.execute("SELECT * from dictcursor where name='bob'")
@@ -80,7 +81,7 @@ def test_DictCursor(self):
8081
yield c.execute("SELECT * from dictcursor")
8182
r = c.fetchmany(2)
8283
self.assertEqual([bob, jim], r, "fetchmany failed via DictCursor")
83-
self._ensure_cursor_expired(c)
84+
yield self._ensure_cursor_expired(c)
8485

8586
@gen_test
8687
def test_custom_dict(self):
@@ -98,7 +99,7 @@ class MyDictCursor(self.cursor_type):
9899
yield cur.execute("SELECT * FROM dictcursor WHERE name='bob'")
99100
r = cur.fetchone()
100101
self.assertEqual(bob, r, "fetchone() returns MyDictCursor")
101-
self._ensure_cursor_expired(cur)
102+
yield self._ensure_cursor_expired(cur)
102103

103104
yield cur.execute("SELECT * FROM dictcursor")
104105
r = cur.fetchall()
@@ -114,14 +115,15 @@ class MyDictCursor(self.cursor_type):
114115
r = cur.fetchmany(2)
115116
self.assertEqual([bob, jim], r,
116117
"list failed via MyDictCursor")
117-
self._ensure_cursor_expired(cur)
118+
yield self._ensure_cursor_expired(cur)
118119

119120

120-
#class TestSSDictCursor(TestDictCursor):
121-
# cursor_type = tornado_mysql.cursors.SSDictCursor
121+
class TestSSDictCursor(TestDictCursor):
122+
cursor_type = tornado_mysql.cursors.SSDictCursor
122123

124+
@gen.coroutine
123125
def _ensure_cursor_expired(self, cursor):
124-
list(cursor.fetchall_unbuffered())
126+
yield cursor.fetchall()
125127

126128
if __name__ == "__main__":
127129
import unittest

0 commit comments

Comments
 (0)