Esempio n. 1
0
 def test_register(self,item):
     url = conf.get('env','url')+ item['url']
     method = item['method']
     parms = eval(replace_data(item['data']))
     expected = eval(replace_data(item['expected']))
     res = requests.request(method=method,url=url,json=parms).json()
     try:
         self.ast.ass(expected,res)
     except AssertionError as e:
         log.info('用例--【{}】---执行失败'.format(item['title']))
         raise e
     else:
         log.info('用例--【{}】---执行成功'.format(item['title']))
Esempio n. 2
0
 def test_createcase(self, item):
     url = conf.get('env', 'url') + item['url']
     method = item['method']
     parms = eval(replace_data(item['data']))
     headers = {"Authorization": getattr(CaseDate, "token")}
     res = requests.request(method=method,
                            url=url,
                            json=parms,
                            headers=headers).json()
     while jsonpath.jsonpath(res, '$.id'):
         CaseDate.caseid = jsonpath.jsonpath(res, '$.id')[0]
         break
     expected = eval(replace_data(item['expected']))
     try:
         self.ast.ass(expected, res)
     except AssertionError as e:
         log.info('用例--【{}】---执行失败'.format(item['title']))
         raise e
     else:
         log.info('用例--【{}】---执行成功'.format(item['title']))