mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
bugfix: check HTTP method before request
This commit is contained in:
@@ -17,6 +17,7 @@ class Context(object):
|
||||
self.testset_shared_variables_mapping = OrderedDict()
|
||||
self.testcase_variables_mapping = OrderedDict()
|
||||
self.testcase_parser = testcase.TestcaseParser()
|
||||
self.evaluated_validators = []
|
||||
self.init_context()
|
||||
|
||||
def init_context(self, level='testset'):
|
||||
|
||||
@@ -156,6 +156,14 @@ class Runner(object):
|
||||
except KeyError:
|
||||
raise exceptions.ParamsError("URL or METHOD missed!")
|
||||
|
||||
# TODO: move method validation to json schema
|
||||
valid_methods = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
|
||||
if method.upper() not in valid_methods:
|
||||
err_msg = u"ParamsError: invalid HTTP method! => {}\n".format(method)
|
||||
err_msg += "available HTTP methods: {}".format("/".join(valid_methods))
|
||||
logger.log_error(err_msg)
|
||||
raise exceptions.ParamsError(err_msg)
|
||||
|
||||
logger.log_info("{method} {url}".format(method=method, url=url))
|
||||
logger.log_debug("request kwargs(raw): {kwargs}".format(kwargs=parsed_request))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user