TestRunner: run single testcase

This commit is contained in:
httprunner
2017-06-21 18:26:02 +08:00
parent b72725e139
commit 3550f1debd
2 changed files with 113 additions and 0 deletions

21
ate/runner.py Normal file
View 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