Skip to content

Commit f26b210

Browse files
committed
CLN: Ignore warnings generated by 'DROP TABLE IF EXISTS' when table does not exist.
1 parent 4db1800 commit f26b210

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pandas/io/tests/test_sql.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from __future__ import with_statement
12
from pandas.util.py3compat import StringIO
23
import unittest
34
import sqlite3
45
import sys
56

7+
import warnings
8+
69
import nose
710

811
import numpy as np
@@ -297,7 +300,9 @@ def test_execute(self):
297300
drop_sql = "DROP TABLE IF EXISTS test"
298301
create_sql = sql.get_schema(frame, 'test', 'mysql')
299302
cur = self.db.cursor()
300-
cur.execute(drop_sql)
303+
with warnings.catch_warnings():
304+
warnings.filterwarnings("ignore", "Unknown table.*")
305+
cur.execute(drop_sql)
301306
cur.execute(create_sql)
302307
ins = "INSERT INTO test VALUES (%s, %s, %s, %s)"
303308

@@ -388,7 +393,9 @@ def _check_roundtrip(self, frame):
388393
_skip_if_no_MySQLdb()
389394
drop_sql = "DROP TABLE IF EXISTS test_table"
390395
cur = self.db.cursor()
391-
cur.execute(drop_sql)
396+
with warnings.catch_warnings():
397+
warnings.filterwarnings("ignore", "Unknown table.*")
398+
cur.execute(drop_sql)
392399
sql.write_frame(frame, name='test_table', con=self.db, flavor='mysql')
393400
result = sql.read_frame("select * from test_table", self.db)
394401

@@ -405,7 +412,9 @@ def _check_roundtrip(self, frame):
405412
frame2['Idx'] = index
406413
drop_sql = "DROP TABLE IF EXISTS test_table2"
407414
cur = self.db.cursor()
408-
cur.execute(drop_sql)
415+
with warnings.catch_warnings():
416+
warnings.filterwarnings("ignore", "Unknown table.*")
417+
cur.execute(drop_sql)
409418
sql.write_frame(frame2, name='test_table2', con=self.db, flavor='mysql')
410419
result = sql.read_frame("select * from test_table2", self.db,
411420
index_col='Idx')

0 commit comments

Comments
 (0)