Commit 6ec407b8 by 文鑫

增加日志

parent 9ba8ec8b
...@@ -5,12 +5,23 @@ import requests ...@@ -5,12 +5,23 @@ import requests
import allure import allure
import pytest import pytest
import sys import sys
import test import os
sys.path.append('../') sys.path.append('../')
import logging
import datetime
from common import getSourceId from common import getSourceId
from common.getData import DoExcelByPandas from common.getData import DoExcelByPandas
dt = datetime.datetime.now().strftime('%Y-%m-%d')
logging.basicConfig(level=logging.DEBUG, #控制台打印的日志级别
filename = os.path.join('../log' ,str(dt) + '.log'), #定义保存日志的路径,使用os.path.join()方法拼接文件路径,其展现为层级关系
filemode = 'a', #模式,有w和a,w就是写模式,每次都会重新写日志,覆盖之前的日志
#a是追加模式,默认如果不写的话,就是追加模式
format=
'%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'
#日志格式
)
@allure.feature('数据源') @allure.feature('数据源')
class TestSource(): class TestSource():
...@@ -24,9 +35,7 @@ class TestSource(): ...@@ -24,9 +35,7 @@ class TestSource():
TRIVIAL = 'trivial'  轻微缺陷  TRIVIAL = 'trivial'  轻微缺陷 
''' '''
parametrize = DoExcelByPandas().get_data_for_pytest('../data/DataA_Source.xlsx', 'Sheet1') parametrize = DoExcelByPandas().get_data_for_pytest('../data/DataA_Source.xlsx', 'Sheet1')
severity = DoExcelByPandas().get_data_for_allure('../data/DataA_Source.xlsx', 'Sheet1') @allure.severity('{severity}')
print(severity)
@allure.severity(severity)
@allure.title('{title}') @allure.title('{title}')
@pytest.mark.parametrize('id,url,data,title,method,severity,condition,except_result', parametrize) @pytest.mark.parametrize('id,url,data,title,method,severity,condition,except_result', parametrize)
def test(self, id, url, data, title, method, severity, condition, except_result): # test开头的测试函数 def test(self, id, url, data, title, method, severity, condition, except_result): # test开头的测试函数
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment