mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
relocate kwargs preparation
This commit is contained in:
@@ -43,6 +43,13 @@ def prepare_kwargs(method, kwargs):
|
|||||||
if charset:
|
if charset:
|
||||||
kwargs["data"] = kwargs["data"].encode(charset)
|
kwargs["data"] = kwargs["data"].encode(charset)
|
||||||
|
|
||||||
|
if "httpntlmauth" in kwargs:
|
||||||
|
from requests_ntlm import HttpNtlmAuth
|
||||||
|
auth_account = kwargs.pop("httpntlmauth")
|
||||||
|
kwargs["auth"] = HttpNtlmAuth(
|
||||||
|
auth_account["username"], auth_account["password"])
|
||||||
|
|
||||||
|
|
||||||
class ApiResponse(Response):
|
class ApiResponse(Response):
|
||||||
|
|
||||||
def raise_for_status(self):
|
def raise_for_status(self):
|
||||||
@@ -127,12 +134,6 @@ class HttpSession(requests.Session):
|
|||||||
# set up pre_request hook for attaching meta data to the request object
|
# set up pre_request hook for attaching meta data to the request object
|
||||||
self.meta_data["method"] = method
|
self.meta_data["method"] = method
|
||||||
|
|
||||||
if "httpntlmauth" in kwargs:
|
|
||||||
from requests_ntlm import HttpNtlmAuth
|
|
||||||
auth_account = kwargs.pop("httpntlmauth")
|
|
||||||
kwargs["auth"] = HttpNtlmAuth(
|
|
||||||
auth_account["username"], auth_account["password"])
|
|
||||||
|
|
||||||
kwargs.setdefault("timeout", 120)
|
kwargs.setdefault("timeout", 120)
|
||||||
|
|
||||||
self.meta_data["request_time"] = time.time()
|
self.meta_data["request_time"] = time.time()
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ class Runner(object):
|
|||||||
if skip_reason:
|
if skip_reason:
|
||||||
raise SkipTest(skip_reason)
|
raise SkipTest(skip_reason)
|
||||||
|
|
||||||
|
def setup_teardown(self, actions):
|
||||||
|
for action in actions:
|
||||||
|
self.context.eval_content(action)
|
||||||
|
|
||||||
def run_test(self, testcase_dict):
|
def run_test(self, testcase_dict):
|
||||||
""" run single testcase.
|
""" run single testcase.
|
||||||
@param (dict) testcase_dict
|
@param (dict) testcase_dict
|
||||||
@@ -135,11 +139,7 @@ class Runner(object):
|
|||||||
|
|
||||||
self._handle_skip_feature(testcase_dict)
|
self._handle_skip_feature(testcase_dict)
|
||||||
|
|
||||||
def setup_teardown(actions):
|
self.setup_teardown(setup_actions)
|
||||||
for action in actions:
|
|
||||||
self.context.eval_content(action)
|
|
||||||
|
|
||||||
setup_teardown(setup_actions)
|
|
||||||
|
|
||||||
resp = self.http_client_session.request(
|
resp = self.http_client_session.request(
|
||||||
method,
|
method,
|
||||||
@@ -171,7 +171,7 @@ class Runner(object):
|
|||||||
|
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
setup_teardown(teardown_actions)
|
self.setup_teardown(teardown_actions)
|
||||||
|
|
||||||
def extract_output(self, output_variables_list):
|
def extract_output(self, output_variables_list):
|
||||||
""" extract output variables
|
""" extract output variables
|
||||||
|
|||||||
Reference in New Issue
Block a user