Exemplo n.º 1
0
 def getReportAttributes(self, result):
     """
     Return report attributes as a list of (name, value).
     Override this to add custom attributes.
     """
     startTime = str(self.startTime)[:19]
     duration = str(self.stopTime - self.startTime)
     status = []
     if result.success_count:
         status.append('Pass %s' % result.success_count)
     if result.failure_count:
         status.append('Failure %s' % result.failure_count)
     if result.error_count: status.append('Error %s' % result.error_count)
     if status:
         status = ' '.join(status)
     else:
         status = 'none'
     self.db = mysqlconnect(self.dbname)
     total2 = result.success_count + result.failure_count + result.error_count + result.skip_count
     # 将执行结果插入数据库
     ipaddress = get_host_ip()
     sql = "INSERT INTO %s (project, sucesss, error, fail, skip, total, starttime, duration, ipaddress) VALUES ('%s', %s, %s, %s, %s, %s, '%s', '%s', '%s')" % (
         result_db.table, project_conf.project, result.success_count,
         result.error_count, result.failure_count, result.skip_count,
         total2, startTime, duration, ipaddress)
     if result_db.isinsert == 1:
         self.dblastid = self.db.getlastid(sql)
     else:
         pass
     return [
         ('Start Time', startTime),
         ('Duration', duration),
         ('Status', status),
     ]
Exemplo n.º 2
0
def insertdb(total):
    '将统计结果写入数据库'
    db = mysqlconnect(result_db.dbname)
    sql = "insert into %s (project, total, starttime) VALUES('%s', %s, '%s')" % (
        result_db.apitable, project_conf.project, total, nowtime)
    db.update_data(sql)
    print('数据库写入完成')
 def setUp(self):
     self.db = mysqlconnect('zgcollection')
Exemplo n.º 4
0
 def setUp(self):
     self.db = mysqlconnect('zgcollmanager')
Exemplo n.º 5
0
 def setUpClass(cls):
     cls.db = mysqlconnect('zgcollection')
     cls.cookie = read('cookies.json')