тестовый код работает: из общего импорта mysqlDB
mysql = mysqlDB.MySQLCommand(****)
sqls = ['DELETE FROM `credit_queue_record`;', 'DELETE FROM `fund_queue_record`;', 'DELETE FROM `installment_bill`;', 'DELETE FROM `kporder_queue_record`;', 'DELETE FROM `order_info`;', 'DELETE FROM `transaction_record`;']
mysql.executeSql(sqls)
sql = 'select id from credit where kp_order_id = \"A15268964292124586\"'
print(mysql.querySql(sql))
когда я использовал его в python unittest, возвращаемое значение равно нулю:
class one2oneTest(unittest.TestCase):
def setUp(self):
#
# empty the tables
#
self.mysql = mysqlDB.MySQLCommand(*********)
sqls = ['DELETE FROM `credit`;', 'DELETE FROM `credit_queue_record`;', 'DELETE FROM `fund_queue_record`;', 'DELETE FROM `installment_bill`;', 'DELETE FROM `kporder_queue_record`;', 'DELETE FROM `order_info`;', 'DELETE FROM `transaction_record`;']
self.mysql.executeSql(sqls)
def test_one2one(self):
sql = 'select id from credit where kp_order_id = \"A15268964292124586\"'
id = self.mysql.querySql(sql)
self.assertIsNotNone(id, msg='id 不应该为空')
запрос sql: выберите идентификатор изкредит, где kp_order_id = "A15268964292124586" Нет
F
FAIL: test_one2one ( main .one2oneTest)
Traceback (последний последний вызов): файл"one2one.py", строка 55, в test_one2one self.assertIsNotNone (id, msg = 'id 不 应该 为 空') AssertionError: неожиданно None: id 不 应该 为 空
класс querySql () имеет вид:def querySql (self, sql): print ("query sql:" + sql)
try:
self.cursor.execute(sql)
row = self.cursor.fetchone()
return row
except:
print(sql + ' execute failed.')
self.conn.rollback()