mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
Merge pull request #14 from diaojunxian/master
bugfix: add maxreplace=1 to avoid similar variables are replaced by mistaken. For instance, if user=1000, then "/$user/$userid" will be replaced to be "/1000/1000id".
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -193,6 +193,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 = {
|
||||
|
||||
Reference in New Issue
Block a user