change: format pytest case after all testcases generated

This commit is contained in:
debugtalk
2020-05-19 11:02:18 +08:00
parent c2ee26d5b5
commit 7ef1ca608c
2 changed files with 6 additions and 5 deletions

View File

@@ -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:

View File

@@ -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