Skip to content

Commit 438254e

Browse files
committed
Fix some tests
1 parent d7cb7ca commit 438254e

File tree

3 files changed

+43
-17
lines changed

3 files changed

+43
-17
lines changed

tornado_mysql/tests/test_DictCursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def tearDown(self):
3838
@gen.coroutine
3939
def shutdown():
4040
c = self.conn.cursor()
41-
c.execute("drop table dictcursor")
41+
yield c.execute("drop table dictcursor")
4242
super(TestDictCursor, self).tearDown()
4343

4444
@gen.coroutine

tornado_mysql/tests/test_SSCursor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def test_SSCursor(self):
3131
cursor = conn.cursor(tornado_mysql.cursors.SSCursor)
3232

3333
# Create table
34-
yield cursor.execute('DROP TABLE IF EXISTS tz_data;')
34+
with warnings.catch_warnings():
35+
warnings.simplefilter("ignore")
36+
yield cursor.execute('DROP TABLE IF EXISTS tz_data;')
3537
yield cursor.execute(('CREATE TABLE tz_data ('
3638
'region VARCHAR(64),'
3739
'zone VARCHAR(64),'
@@ -112,7 +114,9 @@ def test_SSCursor(self):
112114
def _prepare(self):
113115
conn = self.connections[0]
114116
cursor = conn.cursor()
115-
yield cursor.execute('DROP TABLE IF EXISTS tz_data;')
117+
with warnings.catch_warnings():
118+
warnings.simplefilter("ignore")
119+
yield cursor.execute('DROP TABLE IF EXISTS tz_data;')
116120
yield cursor.execute('CREATE TABLE tz_data ('
117121
'region VARCHAR(64),'
118122
'zone VARCHAR(64),'

tornado_mysql/tests/test_issues.py

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def test_issue_3(self):
2323
""" undefined methods datetime_or_None, date_or_None """
2424
conn = self.connections[0]
2525
c = conn.cursor()
26-
yield c.execute("drop table if exists issue3")
26+
with warnings.catch_warnings():
27+
warnings.simplefilter("ignore")
28+
yield c.execute("drop table if exists issue3")
2729
yield c.execute("create table issue3 (d date, t time, dt datetime, ts timestamp)")
2830
try:
2931
yield c.execute("insert into issue3 (d, t, dt, ts) values (%s,%s,%s,%s)", (None, None, None, None))
@@ -43,7 +45,9 @@ def test_issue_4(self):
4345
""" can't retrieve TIMESTAMP fields """
4446
conn = self.connections[0]
4547
c = conn.cursor()
46-
yield c.execute("drop table if exists issue4")
48+
with warnings.catch_warnings():
49+
warnings.simplefilter("ignore")
50+
yield c.execute("drop table if exists issue4")
4751
yield c.execute("create table issue4 (ts timestamp)")
4852
try:
4953
yield c.execute("insert into issue4 (ts) values (now())")
@@ -75,7 +79,9 @@ def test_issue_8(self):
7579
""" Primary Key and Index error when selecting data """
7680
conn = self.connections[0]
7781
c = conn.cursor()
78-
yield c.execute("drop table if exists test")
82+
with warnings.catch_warnings():
83+
warnings.simplefilter("ignore")
84+
yield c.execute("drop table if exists test")
7985
yield c.execute("""CREATE TABLE `test` (`station` int(10) NOT NULL DEFAULT '0', `dh`
8086
datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `echeance` int(1) NOT NULL
8187
DEFAULT '0', `me` double DEFAULT NULL, `mo` double DEFAULT NULL, PRIMARY
@@ -102,9 +108,11 @@ def test_issue_13(self):
102108
""" can't handle large result fields """
103109
conn = self.connections[0]
104110
cur = conn.cursor()
105-
yield cur.execute("drop table if exists issue13")
111+
with warnings.catch_warnings():
112+
warnings.simplefilter("ignore")
113+
yield cur.execute("drop table if exists issue13")
114+
yield cur.execute("create table issue13 (t text)")
106115
try:
107-
yield cur.execute("create table issue13 (t text)")
108116
# ticket says 18k
109117
size = 18*1024
110118
yield cur.execute("insert into issue13 (t) values (%s)", ("x" * size,))
@@ -120,7 +128,9 @@ def test_issue_15(self):
120128
""" query should be expanded before perform character encoding """
121129
conn = self.connections[0]
122130
c = conn.cursor()
123-
yield c.execute("drop table if exists issue15")
131+
with warnings.catch_warnings():
132+
warnings.simplefilter("ignore")
133+
yield c.execute("drop table if exists issue15")
124134
yield c.execute("create table issue15 (t varchar(32))")
125135
try:
126136
yield c.execute("insert into issue15 (t) values (%s)", (u'\xe4\xf6\xfc',))
@@ -134,7 +144,9 @@ def test_issue_16(self):
134144
""" Patch for string and tuple escaping """
135145
conn = self.connections[0]
136146
c = conn.cursor()
137-
yield c.execute("drop table if exists issue16")
147+
with warnings.catch_warnings():
148+
warnings.simplefilter("ignore")
149+
yield c.execute("drop table if exists issue16")
138150
yield c.execute("create table issue16 (name varchar(32) primary key, email varchar(32))")
139151
try:
140152
yield c.execute("insert into issue16 (name, email) values ('pete', 'floydophone')")
@@ -151,9 +163,11 @@ def test_issue_17(self):
151163
db = self.databases[0]["db"]
152164
c = conn.cursor()
153165
# grant access to a table to a user with a password
154-
try:
166+
with warnings.catch_warnings():
167+
warnings.simplefilter("ignore")
155168
yield c.execute("drop table if exists issue17")
156-
yield c.execute("create table issue17 (x varchar(32) primary key)")
169+
yield c.execute("create table issue17 (x varchar(32) primary key)")
170+
try:
157171
yield c.execute("insert into issue17 (x) values ('hello, world!')")
158172
yield c.execute("grant all privileges on %s.issue17 to 'issue17user'@'%%' identified by '1234'" % db)
159173
yield conn.commit()
@@ -180,8 +194,10 @@ def test_issue_34(self):
180194
def test_issue_33(self):
181195
conn = yield tornado_mysql.connect(charset="utf8", **self.databases[0])
182196
c = conn.cursor()
183-
try:
197+
with warnings.catch_warnings():
198+
warnings.simplefilter("ignore")
184199
yield c.execute(b"drop table if exists hei\xc3\x9fe".decode("utf8"))
200+
try:
185201
yield c.execute(b"create table hei\xc3\x9fe (name varchar(32))".decode("utf8"))
186202
yield c.execute(b"insert into hei\xc3\x9fe (name) values ('Pi\xc3\xb1ata')".decode("utf8"))
187203
yield c.execute(b"select name from hei\xc3\x9fe".decode("utf8"))
@@ -246,8 +262,10 @@ def test_issue_38(self):
246262
c = conn.cursor()
247263
datum = "a" * 1024 * 1023 # reduced size for most default mysql installs
248264

249-
try:
265+
with warnings.catch_warnings():
266+
warnings.simplefilter("ignore")
250267
yield c.execute("drop table if exists issue38")
268+
try:
251269
yield c.execute("create table issue38 (id integer, data mediumblob)")
252270
yield c.execute("insert into issue38 values (1, %s)", (datum,))
253271
finally:
@@ -257,7 +275,9 @@ def test_issue_38(self):
257275
def disabled_test_issue_54(self):
258276
conn = self.connections[0]
259277
c = conn.cursor()
260-
yield c.execute("drop table if exists issue54")
278+
with warnings.catch_warnings():
279+
warnings.simplefilter("ignore")
280+
yield c.execute("drop table if exists issue54")
261281
big_sql = "select * from issue54 where "
262282
big_sql += " and ".join("%d=%d" % (i,i) for i in range(0, 100000))
263283

@@ -320,7 +340,9 @@ def test_issue_95(self):
320340
""" Leftover trailing OK packet for "CALL my_sp" queries """
321341
conn = self.connections[0]
322342
cur = conn.cursor()
323-
yield cur.execute("DROP PROCEDURE IF EXISTS `foo`")
343+
with warnings.catch_warnings():
344+
warnings.simplefilter("ignore")
345+
yield cur.execute("DROP PROCEDURE IF EXISTS `foo`")
324346
yield cur.execute("""CREATE PROCEDURE `foo` ()
325347
BEGIN
326348
SELECT 1;
@@ -371,7 +393,7 @@ def test_issue_175(self):
371393
yield cur.execute('select * from test_field_count')
372394
assert len(cur.description) == length
373395
finally:
374-
yield cur.execute('drop table if exists test_field_count')
396+
yield cur.execute('drop table test_field_count')
375397

376398

377399
if __name__ == "__main__":

0 commit comments

Comments
 (0)