def token(self): # res = requests.post(url=url,params=params,auth=auth) c = SendRequest() res = c.send(method=self.method, url=self.url, params=self.params, auth=self.auth) result = res.json()['data']['accessToken'] return result
"creatcases") case = excel.read_data() request = SendRequest() # user = random_user() # em = random_email() url = conf.get("env", "url") + case["url"] case["data"] = CaseData.replace_data(case["data"]) case["data"] = case["data"].replace("@testcases@", random_testcases()) data = eval(case["data"]) CaseData.pass_testcases = data["name"] expected = eval(case["expected"]) headers = eval(conf.get("env", "headers")) headers[ "Authorization"] = "JWT" + " " + "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxNDcsInVzZXJuYW1lIjoic3VubnkwMSIsImV4cCI6MTU4NDkzNTQ3NCwiZW1haWwiOiIxMTE3MkAxNjMuY29tIn0.pVMYwMnzUeuspM0MrqF_ssd5f4qbaOzwmBMvpTFcg7Y" method = case["method"] row = case["case_id"] + 1 # 发送请求 response = request.send(url=url, json=data, headers=headers, method=method) res = response.json() if case["assert"] == "ni": expected = eval(CaseData.replace_data(case["expected"])) print(res) # CaseData.pass_username = jsonpath.jsonpath(res, "$.username")[0] # print(CaseData.pass_username) # CaseData.pass_email = em # print(getattr(CaseData,"pass_email"))