TestRunner: run testcase writen in separate template

This commit is contained in:
httprunner
2017-06-26 11:51:08 +08:00
parent 2fe161f82d
commit 967f2bbc3f
3 changed files with 99 additions and 1 deletions

View File

@@ -1,12 +1,39 @@
import requests
from ate import utils, exception
from ate import exception, utils
from ate.context import Context
from ate.testcase import TestcaseParser
class TestRunner(object):
def __init__(self):
self.client = requests.Session()
self.context = Context()
self.testcase_parser = TestcaseParser()
def prepare(self, testcase):
""" prepare work before running test.
parse testcase with variables binds if it is a template.
"""
requires = testcase.get('requires', [])
self.context.import_requires(requires)
function_binds = testcase.get('function_binds', {})
self.context.bind_functions(function_binds)
variable_binds = testcase.get('variable_binds', [])
self.context.bind_variables(variable_binds)
parsed_testcase = self.testcase_parser.parse(
testcase,
variables_binds=self.context.variables
)
return parsed_testcase
def run_single_testcase(self, testcase):
testcase = self.prepare(testcase)
req_kwargs = testcase['request']
try: