测试代码有效: 来自常见的导入mysqlDB
try{
JSONObject data = response.getJSONObject("entry");
JSONObject content = data.getJSONObject("content");
JSONObject mproperties = content.getJSONObject("mproperties");
JSONObject status = mProperties.getJSONObject("dStatus")
JSONObject charg = mProperties.getJSONObject("dCharg")
String statusText = status.getString("TEXT")
String chargText = charg.getString("TEXT")
}
}catch (JSONException e){
e.printStackTrace();
}
当我在python unittest中使用它时,返回值为null:
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))
查询sql:从credit中选择id,其中kp_order_id =" A15268964292124586" 无
追踪(最近一次通话): 在test_one2one中输入文件" one2one.py",第55行 self.assertIsNotNone(id,msg =' id不应该为空') AssertionError:意外地无:id不应该为空
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 不应该为空')
答案 0 :(得分:0)
在查询之前添加time.sleep(5)。也许我很愚蠢。