mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 23:41:22 +08:00
.env variables should be referenced with builtin ENV/environ function
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
variables:
|
||||
- var_a: 0
|
||||
- var_c: "${sum_two(1, 2)}"
|
||||
- PROJECT_KEY: ${ENV(PROJECT_KEY)}
|
||||
parameters:
|
||||
- "var_a-var_b":
|
||||
- [11, 21]
|
||||
|
||||
@@ -27,7 +27,6 @@ class TestFileLoader(unittest.TestCase):
|
||||
|
||||
os.remove(yaml_tmp_file)
|
||||
|
||||
|
||||
def test_load_json_file_file_format_error(self):
|
||||
json_tmp_file = "tests/data/tmp.json"
|
||||
# create empty file
|
||||
|
||||
@@ -432,8 +432,18 @@ class TestParser(unittest.TestCase):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testcase.yml')
|
||||
testcases = loader.load_tests(testcase_file_path)
|
||||
self.assertEqual(
|
||||
testcases[0]["config"]["variables"][1]["var_c"],
|
||||
"${sum_two(1, 2)}"
|
||||
)
|
||||
self.assertEqual(
|
||||
testcases[0]["config"]["variables"][2]["PROJECT_KEY"],
|
||||
"${ENV(PROJECT_KEY)}"
|
||||
)
|
||||
|
||||
parsed_testcases = parser.parse_tests(testcases)
|
||||
self.assertEqual(parsed_testcases[0]["config"]["variables"]["var_c"], 3)
|
||||
self.assertEqual(parsed_testcases[0]["config"]["variables"]["PROJECT_KEY"], "ABCDEFGH")
|
||||
self.assertEqual(len(parsed_testcases), 2 * 2)
|
||||
self.assertEqual(
|
||||
parsed_testcases[0]["config"]["request"]["base_url"],
|
||||
|
||||
Reference in New Issue
Block a user