evaluate testcase name

This commit is contained in:
httprunner
2018-02-16 00:48:14 +08:00
parent f8569aad91
commit 6e4c48979a
2 changed files with 8 additions and 2 deletions
+5
View File
@@ -168,6 +168,11 @@ class Runner(object):
return True return True
def get_eval_content(self, content):
""" evaluate content with variable bindings
"""
return self.context.testcase_parser.parse_content_with_bindings(content)
def extract_output(self, output_variables_list): def extract_output(self, output_variables_list):
""" extract output variables """ extract output variables
""" """
+3 -2
View File
@@ -72,10 +72,11 @@ class ApiTestSuite(unittest.TestSuite):
def _add_tests_to_suite(self, testcases): def _add_tests_to_suite(self, testcases):
for testcase_dict in testcases: for testcase_dict in testcases:
testcase_name = self.test_runner.get_eval_content(testcase_dict["name"])
if utils.PYTHON_VERSION == 3: if utils.PYTHON_VERSION == 3:
ApiTestCase.runTest.__doc__ = testcase_dict['name'] ApiTestCase.runTest.__doc__ = testcase_name
else: else:
ApiTestCase.runTest.__func__.__doc__ = testcase_dict['name'] ApiTestCase.runTest.__func__.__doc__ = testcase_name
test = ApiTestCase(self.test_runner, testcase_dict) test = ApiTestCase(self.test_runner, testcase_dict)
[self.addTest(test) for _ in range(int(testcase_dict.get("times", 1)))] [self.addTest(test) for _ in range(int(testcase_dict.get("times", 1)))]