mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:59:44 +08:00
bugfix: parse test variables with config variables
This commit is contained in:
@@ -768,6 +768,12 @@ def __parse_tests(tests, config, project_mapping):
|
||||
test_dict.pop("variables", {}),
|
||||
config_variables
|
||||
)
|
||||
# parse test variables with config variables
|
||||
test_dict["variables"] = parse_data(
|
||||
test_dict["variables"],
|
||||
test_dict["variables"],
|
||||
functions
|
||||
)
|
||||
|
||||
# parse test_dict name
|
||||
try:
|
||||
@@ -797,6 +803,12 @@ def __parse_tests(tests, config, project_mapping):
|
||||
test_dict.pop("variables", {}),
|
||||
config_variables
|
||||
)
|
||||
# parse test variables with config variables
|
||||
test_dict["variables"] = parse_data(
|
||||
test_dict["variables"],
|
||||
test_dict["variables"],
|
||||
functions
|
||||
)
|
||||
|
||||
# parse test_dict name
|
||||
try:
|
||||
|
||||
@@ -452,6 +452,34 @@ class TestParser(unittest.TestCase):
|
||||
# self.assertEqual(len(parsed_testcases), 2 * 2)
|
||||
self.assertEqual(parsed_testcases[0]["config"]["name"], '1230')
|
||||
|
||||
def test_parse_tests_fix_override_variables(self):
|
||||
tests_mapping = {
|
||||
'testcases': [
|
||||
{
|
||||
'config': {
|
||||
'name': '',
|
||||
'variables': [
|
||||
{"password": "123456"},
|
||||
{"creator": "user_test_001"}
|
||||
]
|
||||
},
|
||||
'tests': [
|
||||
{
|
||||
'name': 'testcase1',
|
||||
"variables": [
|
||||
{"creator": "user_test_002"},
|
||||
{"username": "$creator"}
|
||||
],
|
||||
'request': {'url': '/api1', 'method': 'GET'}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
parser.parse_tests(tests_mapping)
|
||||
test_dict1_variables = tests_mapping["testcases"][0]["tests"][0]["variables"]
|
||||
self.assertEqual(test_dict1_variables["username"], "user_test_001")
|
||||
|
||||
def test_parse_environ(self):
|
||||
os.environ["PROJECT_KEY"] = "ABCDEFGH"
|
||||
content = {
|
||||
|
||||
Reference in New Issue
Block a user