a. Test Discovery is only found in python 2.7+. unittest2 makes it backwards compatible for python 2.4-2.6

b. Adding traceback from pymysql to debug problems in connecting with database
(cherry picked from commit 81218d718af0ec101f7ba424c62bb6e0b5642744)
This commit is contained in:
Prasanna Santhanam 2011-08-25 19:48:04 +05:30
parent 5ae45e4baf
commit 81366d35c1
2 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,8 @@
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from functools import partial
import os
import sys
@ -37,4 +41,4 @@ class TestCaseExecuteEngine(object):
unittest.TextTestRunner(stream=self.testResultLogFile, verbosity=2).run(suite)

View File

@ -2,6 +2,7 @@ import pymysql
import cloudstackException
import sys
import os
import traceback
class dbConnection(object):
def __init__(self, host="localhost", port=3306, user='cloud', passwd='cloud', db='cloud'):
self.host = host
@ -13,6 +14,7 @@ class dbConnection(object):
try:
self.db = pymysql.Connect(host=host, port=port, user=user, passwd=passwd, db=db)
except:
traceback.print_exc()
raise cloudstackException.InvalidParameterException(sys.exc_info())
def __copy__(self):
@ -73,4 +75,4 @@ if __name__ == "__main__":
for i in range(10):
result = db.execute("select job_status, created, last_updated from async_job where id=%d"%i)
print result