mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
update HttpRunner docstring
This commit is contained in:
+40
-27
@@ -210,11 +210,16 @@ def init_test_suites(path_or_testcases, mapping=None, http_client_session=None):
|
|||||||
class HttpRunner(object):
|
class HttpRunner(object):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
""" initialize test runner
|
""" initialize HttpRunner
|
||||||
@param (dict) kwargs: key-value arguments used to initialize TextTestRunner
|
|
||||||
- resultclass: HtmlTestResult or TextTestResult
|
Args:
|
||||||
- failfast: False/True, stop the test run on the first error or failure.
|
kwargs (dict): key-value arguments used to initialize TextTestRunner.
|
||||||
- dot_env_path: .env file path
|
Commonly used arguments:
|
||||||
|
|
||||||
|
resultclass (class): HtmlTestResult or TextTestResult
|
||||||
|
failfast (bool): False/True, stop the test run on the first error or failure.
|
||||||
|
dot_env_path (str): .env file path
|
||||||
|
|
||||||
"""
|
"""
|
||||||
dot_env_path = kwargs.pop("dot_env_path", None)
|
dot_env_path = kwargs.pop("dot_env_path", None)
|
||||||
env_mapping = loader.load_dot_env_file(dot_env_path)
|
env_mapping = loader.load_dot_env_file(dot_env_path)
|
||||||
@@ -227,21 +232,26 @@ class HttpRunner(object):
|
|||||||
self.runner = unittest.TextTestRunner(**kwargs)
|
self.runner = unittest.TextTestRunner(**kwargs)
|
||||||
|
|
||||||
def run(self, path_or_testcases, mapping=None):
|
def run(self, path_or_testcases, mapping=None):
|
||||||
""" start to run test with varaibles mapping
|
""" start to run test with varaibles mapping.
|
||||||
@param path_or_testcases: YAML/JSON testset file path or testset list
|
|
||||||
path: path could be in several type
|
Args:
|
||||||
- absolute/relative file path
|
path_or_testcases (str/list/dict): YAML/JSON testset file path or testset list
|
||||||
- absolute/relative folder path
|
path: path could be in several type
|
||||||
- list/set container with file(s) and/or folder(s)
|
- absolute/relative file path
|
||||||
testsets: testset or list of testset
|
- absolute/relative folder path
|
||||||
- (dict) testset_dict
|
- list/set container with file(s) and/or folder(s)
|
||||||
- (list) list of testset_dict
|
testsets: testset or list of testset
|
||||||
[
|
- (dict) testset_dict
|
||||||
testset_dict_1,
|
- (list) list of testset_dict
|
||||||
testset_dict_2
|
[
|
||||||
]
|
testset_dict_1,
|
||||||
@param (dict) mapping:
|
testset_dict_2
|
||||||
if mapping specified, it will override variables in config block
|
]
|
||||||
|
mapping (dict): if mapping specified, it will override variables in config block.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
instance: HttpRunner() instance
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
test_suite_list = init_test_suites(path_or_testcases, mapping)
|
test_suite_list = init_test_suites(path_or_testcases, mapping)
|
||||||
@@ -258,8 +268,7 @@ class HttpRunner(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def accumulate_stat(origin_stat, new_stat):
|
def accumulate_stat(origin_stat, new_stat):
|
||||||
""" accumulate new_stat to origin_stat
|
"""accumulate new_stat to origin_stat."""
|
||||||
"""
|
|
||||||
for key in new_stat:
|
for key in new_stat:
|
||||||
if key not in origin_stat:
|
if key not in origin_stat:
|
||||||
origin_stat[key] = new_stat[key]
|
origin_stat[key] = new_stat[key]
|
||||||
@@ -287,11 +296,15 @@ class HttpRunner(object):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def gen_html_report(self, html_report_name=None, html_report_template=None):
|
def gen_html_report(self, html_report_name=None, html_report_template=None):
|
||||||
""" generate html report and return report path
|
""" generate html report and return report path.
|
||||||
@param (str) html_report_name:
|
|
||||||
output html report file name
|
Args:
|
||||||
@param (str) html_report_template:
|
html_report_name (str): output html report file name
|
||||||
report template file path, template should be in Jinja2 format
|
html_report_template (str): report template file path, template should be in Jinja2 format
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: generated html report path
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return render_html_report(
|
return render_html_report(
|
||||||
self.summary,
|
self.summary,
|
||||||
|
|||||||
Reference in New Issue
Block a user