Skip to content

Commit 643036b

Browse files
author
Alexander Smishlajev
committed
connection availability check merged from HEAD
1 parent 691e217 commit 643036b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/test_mysql.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17-
#
18-
# $Id: test_mysql.py,v 1.9 2004-03-24 06:18:59 richard Exp $
17+
#
18+
# $Id: test_mysql.py,v 1.9.2.1 2004-10-01 09:04:13 a1s Exp $
1919

2020
import unittest, os, shutil, time, imp
2121

@@ -94,12 +94,12 @@ def test_suite():
9494
return suite
9595

9696
from roundup.backends import mysql
97+
import MySQLdb
9798
try:
98-
# Check if we can run mysql tests
99-
import MySQLdb
100-
db = mysql.Database(config, 'admin')
101-
db.close()
102-
except (MySQLdb.ProgrammingError, DatabaseError), msg:
99+
# Check if we can connect to the server.
100+
# use db_exists() to make a connection, ignore it's return value
101+
mysql.db_exists(config)
102+
except (MySQLdb.MySQLError, DatabaseError), msg:
103103
print "Skipping mysql tests (%s)"%msg
104104
else:
105105
print 'Including mysql tests'
@@ -114,3 +114,4 @@ def test_suite():
114114
runner = unittest.TextTestRunner()
115115
unittest.main(testRunner=runner)
116116

117+
# vim: set et sts=4 sw=4 :

0 commit comments

Comments
 (0)