mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 07:21:23 +08:00
fix bug|>update parse_variables and add testcase test_parse_variables_multiple_identical_variables
This commit is contained in:
@@ -49,7 +49,7 @@ def parse_variables(content, variable_mapping):
|
|||||||
# content contains one or many variables
|
# content contains one or many variables
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
"${}".format(variable_name),
|
"${}".format(variable_name),
|
||||||
str(variable_value)
|
str(variable_value), 1
|
||||||
)
|
)
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|||||||
@@ -188,6 +188,19 @@ class TestcaseParserUnittest(unittest.TestCase):
|
|||||||
"/users/100/training/1498?userId=100&data=1498"
|
"/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):
|
def test_parse_content_with_bindings_functions(self):
|
||||||
import random, string
|
import random, string
|
||||||
functions_binds = {
|
functions_binds = {
|
||||||
|
|||||||
Reference in New Issue
Block a user