fix base_url: teststep have base_url but is empty

This commit is contained in:
debugtalk
2018-11-29 19:31:11 +08:00
parent bc70c3b204
commit 630b9e7e8a
2 changed files with 39 additions and 11 deletions

View File

@@ -499,10 +499,6 @@ class TestParser(unittest.TestCase):
{
'name': 'testcase1',
"base_url": "https://httprunner.org",
"variables": [
{"creator": "user_test_002"},
{"username": "$creator"}
],
'request': {'url': '/api1', 'method': 'GET', "verify": True}
}
]
@@ -569,6 +565,35 @@ class TestParser(unittest.TestCase):
test_dict = tests_mapping["testcases"][0]["tests"][0]
self.assertEqual(test_dict["request"]["url"], "https://httprunner.org/api1")
def test_parse_tests_base_url_teststep_empty(self):
""" base_url & verify: priority test_dict > config
"""
tests_mapping = {
'testcases': [
{
'config': {
'name': '',
"base_url": "$host",
'variables': {
"host": "https://debugtalk"
},
"verify": False
},
'tests': [
{
'name': 'testcase1',
"base_url": "",
'request': {'url': '/api1', 'method': 'GET', "verify": True}
}
]
}
]
}
parser.parse_tests(tests_mapping)
test_dict = tests_mapping["testcases"][0]["tests"][0]
self.assertEqual(test_dict["request"]["url"], "https://debugtalk/api1")
self.assertEqual(test_dict["request"]["verify"], True)
def test_parse_environ(self):
os.environ["PROJECT_KEY"] = "ABCDEFGH"
content = {