From 182fbb6aeb0e3000b6d69dd6a727170b4d4ff909 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 16 Feb 2018 00:48:14 +0800 Subject: [PATCH] evaluate testcase name --- httprunner/runner.py | 5 +++++ httprunner/task.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/httprunner/runner.py b/httprunner/runner.py index 2194fff8..d3b5178c 100644 --- a/httprunner/runner.py +++ b/httprunner/runner.py @@ -168,6 +168,11 @@ class Runner(object): 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): """ extract output variables """ diff --git a/httprunner/task.py b/httprunner/task.py index 647b5bea..c30ea06b 100644 --- a/httprunner/task.py +++ b/httprunner/task.py @@ -72,10 +72,11 @@ class ApiTestSuite(unittest.TestSuite): def _add_tests_to_suite(self, testcases): for testcase_dict in testcases: + testcase_name = self.test_runner.get_eval_content(testcase_dict["name"]) if utils.PYTHON_VERSION == 3: - ApiTestCase.runTest.__doc__ = testcase_dict['name'] + ApiTestCase.runTest.__doc__ = testcase_name else: - ApiTestCase.runTest.__func__.__doc__ = testcase_dict['name'] + ApiTestCase.runTest.__func__.__doc__ = testcase_name test = ApiTestCase(self.test_runner, testcase_dict) [self.addTest(test) for _ in range(int(testcase_dict.get("times", 1)))]