mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 14:59:38 +08:00
TestRunner: run single testcase
This commit is contained in:
21
ate/runner.py
Normal file
21
ate/runner.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import requests
|
||||
from ate import utils, exception
|
||||
|
||||
class TestRunner(object):
|
||||
|
||||
def __init__(self):
|
||||
self.client = requests.Session()
|
||||
|
||||
def run_single_testcase(self, testcase):
|
||||
req_kwargs = testcase['request']
|
||||
|
||||
try:
|
||||
url = req_kwargs.pop('url')
|
||||
method = req_kwargs.pop('method')
|
||||
except KeyError:
|
||||
raise exception.ParamsError("Params Error")
|
||||
|
||||
resp_obj = self.client.request(url=url, method=method, **req_kwargs)
|
||||
diff_content = utils.diff_response(resp_obj, testcase['response'])
|
||||
success = False if diff_content else True
|
||||
return success, diff_content
|
||||
Reference in New Issue
Block a user