mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 11:29:48 +08:00
load_testcases_by_path: make compatible with none exist path
This commit is contained in:
@@ -167,7 +167,7 @@ def load_testcases_by_path(path):
|
||||
files_list = load_foler_files(path)
|
||||
return load_testcases_by_path(files_list)
|
||||
|
||||
if os.path.isfile(path):
|
||||
elif os.path.isfile(path):
|
||||
testset = {
|
||||
"name": "",
|
||||
"config": {},
|
||||
@@ -187,3 +187,6 @@ def load_testcases_by_path(path):
|
||||
testset["testcases"].append(item["test"])
|
||||
|
||||
return [testset]
|
||||
|
||||
else:
|
||||
return []
|
||||
|
||||
@@ -306,3 +306,22 @@ class TestUtils(ApiServerUnittest):
|
||||
]
|
||||
testset_list_3 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list_3), 2 * len(testset_list_1))
|
||||
|
||||
def test_load_testcases_by_path_not_exist(self):
|
||||
# absolute folder path
|
||||
path = os.path.join(os.getcwd(), 'test/data_not_exist')
|
||||
testset_list_1 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(testset_list_1, [])
|
||||
|
||||
# relative folder path
|
||||
path = 'test/data_not_exist'
|
||||
testset_list_2 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(testset_list_2, [])
|
||||
|
||||
# list/set container with file(s)
|
||||
path = [
|
||||
os.path.join(os.getcwd(), 'test/data_not_exist'),
|
||||
'test/data_not_exist/'
|
||||
]
|
||||
testset_list_3 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(testset_list_3, [])
|
||||
|
||||
Reference in New Issue
Block a user