mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 09:49:33 +08:00
fix: handle errors when no valid testcases generated
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
**Fixed**
|
**Fixed**
|
||||||
|
|
||||||
- fix: extract response cookies
|
- fix: extract response cookies
|
||||||
|
- fix: handle errors when no valid testcases generated
|
||||||
|
|
||||||
## 3.0.3 (2020-05-17)
|
## 3.0.3 (2020-05-17)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
from httprunner import __description__, __version__, exceptions
|
from httprunner import __description__, __version__, exceptions
|
||||||
from httprunner.ext.har2case import init_har2case_parser, main_har2case
|
from httprunner.ext.har2case import init_har2case_parser, main_har2case
|
||||||
@@ -33,7 +34,10 @@ def main_run(extra_args):
|
|||||||
# has not specified any testcase path
|
# has not specified any testcase path
|
||||||
raise exceptions.ParamsError("Missed testcase path")
|
raise exceptions.ParamsError("Missed testcase path")
|
||||||
|
|
||||||
main_make(tests_path_list)
|
testcase_path_list = main_make(tests_path_list)
|
||||||
|
if not testcase_path_list:
|
||||||
|
logger.error("No valid testcases found, exit 1.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if "-s" not in extra_args:
|
if "-s" not in extra_args:
|
||||||
extra_args.insert(0, "-s")
|
extra_args.insert(0, "-s")
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ def format_with_black(tests_path: Text):
|
|||||||
logger.error(ex)
|
logger.error(ex)
|
||||||
|
|
||||||
|
|
||||||
def make(tests_path: Text) -> List:
|
def __make(tests_path: Text) -> List:
|
||||||
testcases = []
|
testcases = []
|
||||||
if os.path.isdir(tests_path):
|
if os.path.isdir(tests_path):
|
||||||
files_list = load_folder_files(tests_path)
|
files_list = load_folder_files(tests_path)
|
||||||
@@ -106,6 +106,10 @@ def make(tests_path: Text) -> List:
|
|||||||
continue
|
continue
|
||||||
testcase_path_list.append(testcase_path)
|
testcase_path_list.append(testcase_path)
|
||||||
|
|
||||||
|
if not testcase_path_list:
|
||||||
|
logger.warning(f"No valid testcase generated on {tests_path}")
|
||||||
|
return []
|
||||||
|
|
||||||
format_with_black(tests_path)
|
format_with_black(tests_path)
|
||||||
return testcase_path_list
|
return testcase_path_list
|
||||||
|
|
||||||
@@ -113,7 +117,7 @@ def make(tests_path: Text) -> List:
|
|||||||
def main_make(tests_paths: List[Text]) -> List:
|
def main_make(tests_paths: List[Text]) -> List:
|
||||||
testcase_path_list = []
|
testcase_path_list = []
|
||||||
for tests_path in tests_paths:
|
for tests_path in tests_paths:
|
||||||
testcase_path_list.extend(make(tests_path))
|
testcase_path_list.extend(__make(tests_path))
|
||||||
|
|
||||||
return testcase_path_list
|
return testcase_path_list
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user