From e49ebb7e9af1c632e32ff183bfd5303070b4379e Mon Sep 17 00:00:00 2001 From: diaojunxian Date: Wed, 2 Aug 2017 14:19:24 +0800 Subject: [PATCH] fix bug|>update parse_variables and add testcase test_parse_variables_multiple_identical_variables --- ate/testcase.py | 2 +- tests/test_testcase.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ate/testcase.py b/ate/testcase.py index 305da840..5ebd33d4 100644 --- a/ate/testcase.py +++ b/ate/testcase.py @@ -49,7 +49,7 @@ def parse_variables(content, variable_mapping): # content contains one or many variables content = content.replace( "${}".format(variable_name), - str(variable_value) + str(variable_value), 1 ) return content diff --git a/tests/test_testcase.py b/tests/test_testcase.py index 44ef2678..371dffdb 100644 --- a/tests/test_testcase.py +++ b/tests/test_testcase.py @@ -188,6 +188,19 @@ class TestcaseParserUnittest(unittest.TestCase): "/users/100/training/1498?userId=100&data=1498" ) + def test_parse_variables_multiple_identical_variables(self): + variables_binds = { + "user": 100, + "userid": 1000, + "data": 1498 + } + content = "/users/$user/$userid/$data?userId=$userid&data=$data" + self.assertEqual( + testcase.parse_content_with_bindings(content, variables_binds, {}), + "/users/100/1000/1498?userId=1000&data=1498" + ) + + def test_parse_content_with_bindings_functions(self): import random, string functions_binds = {