mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 11:36:56 +08:00
bugfix verify priority: teststep > config
This commit is contained in:
@@ -794,9 +794,12 @@ def __parse_testcase_tests(tests, config, project_mapping):
|
|||||||
variables priority:
|
variables priority:
|
||||||
testcase config > testcase test > testcase_def config > testcase_def test > api
|
testcase config > testcase test > testcase_def config > testcase_def test > api
|
||||||
|
|
||||||
base_url/verify priority:
|
base_url priority:
|
||||||
testcase test > testcase config > testsuite test > testsuite config > api
|
testcase test > testcase config > testsuite test > testsuite config > api
|
||||||
|
|
||||||
|
verify priority:
|
||||||
|
testcase teststep (api) > testcase config > testsuite config
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tests (list):
|
tests (list):
|
||||||
config (dict):
|
config (dict):
|
||||||
@@ -814,8 +817,6 @@ def __parse_testcase_tests(tests, config, project_mapping):
|
|||||||
if (not test_dict.get("base_url")) and config_base_url:
|
if (not test_dict.get("base_url")) and config_base_url:
|
||||||
test_dict["base_url"] = config_base_url
|
test_dict["base_url"] = config_base_url
|
||||||
|
|
||||||
test_dict.setdefault("verify", config_verify)
|
|
||||||
|
|
||||||
# 1, testcase config => testcase tests
|
# 1, testcase config => testcase tests
|
||||||
# override test_dict variables
|
# override test_dict variables
|
||||||
test_dict["variables"] = utils.extend_variables(
|
test_dict["variables"] = utils.extend_variables(
|
||||||
@@ -875,6 +876,10 @@ def __parse_testcase_tests(tests, config, project_mapping):
|
|||||||
request_url
|
request_url
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# verify priority: testcase teststep > testcase config
|
||||||
|
if "request" in test_dict and "verify" not in test_dict["request"]:
|
||||||
|
test_dict["request"]["verify"] = config_verify
|
||||||
|
|
||||||
|
|
||||||
def _parse_testcase(testcase, project_mapping):
|
def _parse_testcase(testcase, project_mapping):
|
||||||
""" parse testcase
|
""" parse testcase
|
||||||
|
|||||||
@@ -732,6 +732,77 @@ class TestParser(unittest.TestCase):
|
|||||||
self.assertEqual(test_dict["request"]["url"], "https://debugtalk.com/api1")
|
self.assertEqual(test_dict["request"]["url"], "https://debugtalk.com/api1")
|
||||||
self.assertEqual(test_dict["request"]["verify"], True)
|
self.assertEqual(test_dict["request"]["verify"], True)
|
||||||
|
|
||||||
|
def test_parse_tests_verify_config_set(self):
|
||||||
|
""" verify priority: test_dict > config
|
||||||
|
"""
|
||||||
|
tests_mapping = {
|
||||||
|
'testcases': [
|
||||||
|
{
|
||||||
|
"config": {
|
||||||
|
'name': 'bugfix verify',
|
||||||
|
"base_url": "https://httpbin.org/",
|
||||||
|
"verify": False
|
||||||
|
},
|
||||||
|
"teststeps": [
|
||||||
|
{
|
||||||
|
'name': 'testcase1',
|
||||||
|
'request': {'url': '/headers', 'method': 'GET'}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
parsed_tests_mapping = parser.parse_tests(tests_mapping)
|
||||||
|
test_dict = parsed_tests_mapping["testcases"][0]["teststeps"][0]
|
||||||
|
self.assertEqual(test_dict["request"]["verify"], False)
|
||||||
|
|
||||||
|
def test_parse_tests_verify_config_unset(self):
|
||||||
|
""" verify priority: test_dict > config
|
||||||
|
"""
|
||||||
|
tests_mapping = {
|
||||||
|
'testcases': [
|
||||||
|
{
|
||||||
|
"config": {
|
||||||
|
'name': 'bugfix verify',
|
||||||
|
"base_url": "https://httpbin.org/",
|
||||||
|
},
|
||||||
|
"teststeps": [
|
||||||
|
{
|
||||||
|
'name': 'testcase1',
|
||||||
|
'request': {'url': '/headers', 'method': 'GET'}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
parsed_tests_mapping = parser.parse_tests(tests_mapping)
|
||||||
|
test_dict = parsed_tests_mapping["testcases"][0]["teststeps"][0]
|
||||||
|
self.assertEqual(test_dict["request"]["verify"], True)
|
||||||
|
|
||||||
|
def test_parse_tests_verify_step_set_false(self):
|
||||||
|
""" verify priority: test_dict > config
|
||||||
|
"""
|
||||||
|
tests_mapping = {
|
||||||
|
'testcases': [
|
||||||
|
{
|
||||||
|
"config": {
|
||||||
|
'name': 'bugfix verify',
|
||||||
|
"base_url": "https://httpbin.org/",
|
||||||
|
"verify": True
|
||||||
|
},
|
||||||
|
"teststeps": [
|
||||||
|
{
|
||||||
|
'name': 'testcase1',
|
||||||
|
'request': {'url': '/headers', 'method': 'GET', "verify": False}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
parsed_tests_mapping = parser.parse_tests(tests_mapping)
|
||||||
|
test_dict = parsed_tests_mapping["testcases"][0]["teststeps"][0]
|
||||||
|
self.assertEqual(test_dict["request"]["verify"], False)
|
||||||
|
|
||||||
def test_parse_environ(self):
|
def test_parse_environ(self):
|
||||||
os.environ["PROJECT_KEY"] = "ABCDEFGH"
|
os.environ["PROJECT_KEY"] = "ABCDEFGH"
|
||||||
content = {
|
content = {
|
||||||
|
|||||||
Reference in New Issue
Block a user