mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-14 04:29:43 +08:00
remove unused code
This commit is contained in:
@@ -16,14 +16,11 @@ class HttpRunner(object):
|
||||
kwargs (dict): key-value arguments used to initialize TextTestRunner.
|
||||
Commonly used arguments:
|
||||
|
||||
resultclass (class): HtmlTestResult or TextTestResult
|
||||
failfast (bool): False/True, stop the test run on the first error or failure.
|
||||
http_client_session (instance): requests.Session(), or locust.client.Session() instance.
|
||||
|
||||
"""
|
||||
self.exception_stage = "initialize HttpRunner()"
|
||||
self.http_client_session = kwargs.pop("http_client_session", None)
|
||||
kwargs.setdefault("resultclass", report.HtmlTestResult)
|
||||
kwargs["resultclass"] = report.HtmlTestResult
|
||||
self.unittest_runner = unittest.TextTestRunner(**kwargs)
|
||||
self.test_loader = unittest.TestLoader()
|
||||
self.summary = None
|
||||
@@ -63,7 +60,7 @@ class HttpRunner(object):
|
||||
|
||||
for testcase in tests_mapping["testcases"]:
|
||||
config = testcase.get("config", {})
|
||||
test_runner = runner.Runner(config, functions, self.http_client_session)
|
||||
test_runner = runner.Runner(config, functions)
|
||||
TestSequense = type('TestSequense', (unittest.TestCase,), {})
|
||||
|
||||
tests = testcase.get("tests", [])
|
||||
@@ -125,7 +122,6 @@ class HttpRunner(object):
|
||||
|
||||
self.summary["success"] &= testcase_summary["success"]
|
||||
testcase_summary["name"] = testcase.config.get("name")
|
||||
testcase_summary["base_url"] = testcase.config.get("request", {}).get("base_url", "")
|
||||
|
||||
in_out = utils.get_testcase_io(testcase)
|
||||
utils.print_io(in_out)
|
||||
|
||||
@@ -870,13 +870,6 @@ def parse_tests(tests_mapping):
|
||||
"""
|
||||
project_mapping = tests_mapping.get("project_mapping", {})
|
||||
|
||||
env_mapping = project_mapping.get("env", {})
|
||||
# set OS environment variables
|
||||
utils.set_os_environ(env_mapping)
|
||||
|
||||
for testcase in tests_mapping["testcases"]:
|
||||
testcase.setdefault("config", {})
|
||||
_parse_testcase(testcase, project_mapping)
|
||||
|
||||
# unset OS environment variables
|
||||
utils.unset_os_environ(env_mapping)
|
||||
|
||||
@@ -28,6 +28,10 @@ def get_platform():
|
||||
|
||||
def get_summary(result):
|
||||
""" get summary from test result
|
||||
|
||||
Args:
|
||||
result (instance): HtmlTestResult() instance
|
||||
|
||||
"""
|
||||
summary = {
|
||||
"success": result.wasSuccessful(),
|
||||
@@ -47,14 +51,11 @@ def get_summary(result):
|
||||
- summary["stat"]["expectedFailures"] \
|
||||
- summary["stat"]["unexpectedSuccesses"]
|
||||
|
||||
if getattr(result, "records", None):
|
||||
summary["time"] = {
|
||||
'start_at': result.start_at,
|
||||
'duration': result.duration
|
||||
}
|
||||
summary["records"] = result.records
|
||||
else:
|
||||
summary["records"] = []
|
||||
summary["time"] = {
|
||||
'start_at': result.start_at,
|
||||
'duration': result.duration
|
||||
}
|
||||
summary["records"] = result.records
|
||||
|
||||
return summary
|
||||
|
||||
@@ -173,9 +174,8 @@ def stringify_data(meta_data, request_or_response):
|
||||
|
||||
|
||||
class HtmlTestResult(unittest.TextTestResult):
|
||||
"""A html result class that can generate formatted html results.
|
||||
|
||||
Used by TextTestRunner.
|
||||
""" A html result class that can generate formatted html results.
|
||||
Used by TextTestRunner.
|
||||
"""
|
||||
def __init__(self, stream, descriptions, verbosity):
|
||||
super(HtmlTestResult, self).__init__(stream, descriptions, verbosity)
|
||||
|
||||
Reference in New Issue
Block a user