comparison test/test_mysql.py @ 2694:91fdaaf8d929

use mysql.db_exists() instead of mysql.Database to test connection availability: mysql.Database requires existing roundup database to connect.
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Sun, 26 Sep 2004 15:18:28 +0000
parents 09651970063b
children adec352e2ce0
comparison
equal deleted inserted replaced
2693:59ea85d47d34 2694:91fdaaf8d929
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: test_mysql.py,v 1.12 2004-09-26 11:30:56 a1s Exp $ 18 # $Id: test_mysql.py,v 1.13 2004-09-26 15:18:28 a1s Exp $
19 19
20 import unittest, os, shutil, time, imp 20 import unittest, os, shutil, time, imp
21 21
22 from roundup.hyperdb import DatabaseError 22 from roundup.hyperdb import DatabaseError
23 from roundup import init, backends 23 from roundup import init, backends
77 if not hasattr(backends, 'mysql'): 77 if not hasattr(backends, 'mysql'):
78 print "Skipping mysql tests" 78 print "Skipping mysql tests"
79 return suite 79 return suite
80 80
81 from roundup.backends import mysql 81 from roundup.backends import mysql
82 import MySQLdb
82 try: 83 try:
83 # Check if we can run mysql tests 84 # Check if we can connect to the server.
84 import MySQLdb 85 # use db_exists() to make a connection, ignore it's return value
85 db = mysql.Database(config, 'admin') 86 mysql.db_exists(config)
86 db.close()
87 except (MySQLdb.MySQLError, DatabaseError), msg: 87 except (MySQLdb.MySQLError, DatabaseError), msg:
88 print "Skipping mysql tests (%s)"%msg 88 print "Skipping mysql tests (%s)"%msg
89 else: 89 else:
90 print 'Including mysql tests' 90 print 'Including mysql tests'
91 suite.addTest(unittest.makeSuite(mysqlDBTest)) 91 suite.addTest(unittest.makeSuite(mysqlDBTest))

Roundup Issue Tracker: http://roundup-tracker.org/