Skip to content

Commit 40e09e0

Browse files
author
Thomas Grainger
committed
Fix TestXMySQL
1 parent 71fd12e commit 40e09e0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/io/tests/test_sql.py

+10
Original file line numberDiff line numberDiff line change
@@ -2237,6 +2237,7 @@ def setUp(self):
22372237
except:
22382238
pass
22392239
else:
2240+
self.addCleanup(self._try_close_db)
22402241
return
22412242
try:
22422243
self.db = pymysql.connect(read_default_group='pandas')
@@ -2251,6 +2252,15 @@ def setUp(self):
22512252
"Create a group of connection parameters under the heading "
22522253
"[pandas] in your system's mysql default file, "
22532254
"typically located at ~/.my.cnf or /etc/.my.cnf. ")
2255+
else:
2256+
self.addCleanup(self._try_close_db)
2257+
2258+
def _try_close_db(self):
2259+
from pymysql.err import Error
2260+
try:
2261+
self.db.close()
2262+
except Error:
2263+
pass
22542264

22552265
def test_basic(self):
22562266
_skip_if_no_pymysql()

0 commit comments

Comments
 (0)