pytestパラメータ化とallure注記(継続的な更新)


前提条件:私の使用例はxlsxに書いてあります.(インタフェースはテスト読取方法と同じ)
 
まず、xlsxインスタンスファイルを読み込む

import xlrd,json

def getCase(filepath,index):
    try:
        file = xlrd.open_workbook(filepath)
        me = file.sheets()[index]
        nrows = me.nrows
        listdata = []
        for i in range(1, nrows):
            dict_canshu = {}
            if me.cell(i, 1).value=='Y':
                dict_canshu['id'] = me.cell(i, 0).value
                dict_canshu.setdefault('active',me.cell(i, 1).value)
                dict_canshu.setdefault('apiname', me.cell(i, 2).value)
                dict_canshu.setdefault('apihost',me.cell(i,3).value)
                dict_canshu.setdefault('url',me.cell(i, 4).value)
                dict_canshu.setdefault('method', me.cell(i, 5).value)
                dict_canshu.setdefault('redata', me.cell(i, 6).value)
                dict_canshu.setdefault('assert', me.cell(i, 7).value)
                dict_canshu.setdefault('sql', me.cell(i, 8).value)
                dict_canshu.setdefault('desc', me.cell(i, 9).value)
                listdata.append(dict_canshu)
        return listdata
    except Exception as e:
        log.error(' , :%s'%e)


import pytest,allure,Path,json
from interface.data.readCase import getCase
from interface.case.BaseThread import BaseThread
from common.httpHandle import httpHandle

class Test_api_case(object):
    @classmethod
    def setup_class(cls):
        cls.http=httpHandle()
        cls.req=None
        cls.result = None
    @pytest.mark.parametrize(('casedata'),getCase(Path.apicasPath(),0))
    def test_case(self,casedata):
        allure.dynamic.title(casedata['apiname'])
        allure.dynamic.description(casedata['apiname'])
        self.req=casedata
        self.thread = BaseThread(casedata,self.http)
        self.thread.start()

    def teardown(cls):
        cls.result = cls.thread.join()
        print(' :', cls.req)
        print(' :', cls.result)
        cls.j=json.loads(cls.result)
        cls.code=cls.j['statusCode']
        assert  cls.code==200

, QQ 833077481