mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 15:31:23 +08:00
move print_output function from runner.py to utils.py
This commit is contained in:
@@ -172,12 +172,10 @@ class Runner(object):
|
|||||||
success = False
|
success = False
|
||||||
|
|
||||||
output_variables_list = config_dict.get("output", [])
|
output_variables_list = config_dict.get("output", [])
|
||||||
output = self.generate_output(output_variables_list)
|
|
||||||
self.print_output(output)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": success,
|
"success": success,
|
||||||
"output": output
|
"output": self.generate_output(output_variables_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
def run_testsets(self, testsets):
|
def run_testsets(self, testsets):
|
||||||
@@ -200,21 +198,13 @@ class Runner(object):
|
|||||||
return success
|
return success
|
||||||
|
|
||||||
def generate_output(self, output_variables_list):
|
def generate_output(self, output_variables_list):
|
||||||
|
""" generate and print output
|
||||||
|
"""
|
||||||
variables_mapping = self.context.get_testcase_variables_mapping()
|
variables_mapping = self.context.get_testcase_variables_mapping()
|
||||||
return {
|
output = {
|
||||||
variable: variables_mapping[variable]
|
variable: variables_mapping[variable]
|
||||||
for variable in output_variables_list
|
for variable in output_variables_list
|
||||||
}
|
}
|
||||||
|
utils.print_output(output)
|
||||||
|
|
||||||
def print_output(self, output):
|
return output
|
||||||
if not output:
|
|
||||||
return
|
|
||||||
|
|
||||||
print("\n================== Output ==================")
|
|
||||||
print('{:<10}: {:<}'.format("Variable", "Value"))
|
|
||||||
print('{:<10}: {:<}'.format("--------", "-----"))
|
|
||||||
|
|
||||||
for variable, value in output.items():
|
|
||||||
print('{:<10}: {:<}'.format(variable, value))
|
|
||||||
|
|
||||||
print("============================================\n")
|
|
||||||
|
|||||||
13
ate/utils.py
13
ate/utils.py
@@ -359,3 +359,16 @@ def override_variables_binds(variable_binds, new_mapping):
|
|||||||
convert_to_order_dict(variable_binds),
|
convert_to_order_dict(variable_binds),
|
||||||
new_mapping
|
new_mapping
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def print_output(output):
|
||||||
|
if not output:
|
||||||
|
return
|
||||||
|
|
||||||
|
print("\n================== Output ==================")
|
||||||
|
print('{:<10}: {:<}'.format("Variable", "Value"))
|
||||||
|
print('{:<10}: {:<}'.format("--------", "-----"))
|
||||||
|
|
||||||
|
for variable, value in output.items():
|
||||||
|
print('{:<10}: {:<}'.format(variable, value))
|
||||||
|
|
||||||
|
print("============================================\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user