From 7ef1ca608c9a3f2469b0bb252ada2d29aa4c6aee Mon Sep 17 00:00:00 2001 From: debugtalk Date: Tue, 19 May 2020 11:02:18 +0800 Subject: [PATCH] change: format pytest case after all testcases generated --- httprunner/cli.py | 3 ++- httprunner/ext/make/__init__.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/httprunner/cli.py b/httprunner/cli.py index 68f67b21..f5f5655f 100644 --- a/httprunner/cli.py +++ b/httprunner/cli.py @@ -31,7 +31,8 @@ def main_run(extra_args): if len(tests_path_list) == 0: # has not specified any testcase path - raise exceptions.ParamsError("Missed testcase path") + logger.error(f"No valid testcase path in cli arguments: {extra_args}") + sys.exit(1) testcase_path_list = main_make(tests_path_list) if not testcase_path_list: diff --git a/httprunner/ext/make/__init__.py b/httprunner/ext/make/__init__.py index 466dddd1..b4652553 100644 --- a/httprunner/ext/make/__init__.py +++ b/httprunner/ext/make/__init__.py @@ -59,10 +59,10 @@ def convert_testcase_path(testcase_path: Text) -> Tuple[Text, Text]: return testcase_python_path, name_in_title_case -def format_pytest_with_black(python_path: Text): - logger.info(f"format pytest case with black: {python_path}") +def format_pytest_with_black(python_paths: List[Text]): + logger.info("format pytest case with black ...") try: - subprocess.run(["black", python_path]) + subprocess.run(["black", *python_paths]) except subprocess.CalledProcessError as ex: logger.error(ex) @@ -106,7 +106,6 @@ def make_testcase(testcase: Dict) -> Union[str, None]: f.write(content) logger.info(f"generated testcase: {testcase_python_path}") - format_pytest_with_black(testcase_python_path) return testcase_python_path @@ -222,6 +221,7 @@ def main_make(tests_paths: List[Text]) -> List: for tests_path in tests_paths: testcase_path_list.extend(__make(tests_path)) + format_pytest_with_black(testcase_path_list) return testcase_path_list