fix: compatibility for black on Android termux system that does not support multiprocessing

This commit is contained in:
debugtalk
2020-06-28 20:45:07 +08:00
parent 2c638ed52c
commit 25c10af750
3 changed files with 22 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ from httprunner.loader import (
convert_relative_project_root_dir,
)
from httprunner.response import uniform_validator
from httprunner.utils import override_config_variables
from httprunner.utils import override_config_variables, is_support_multiprocessing
""" cache converted pytest files, avoid duplicate making
"""
@@ -160,7 +160,13 @@ def convert_testcase_path(testcase_abs_path: Text) -> Tuple[Text, Text]:
def format_pytest_with_black(*python_paths: Text) -> NoReturn:
logger.info("format pytest cases with black ...")
try:
subprocess.run(["black", *python_paths])
if is_support_multiprocessing() or len(python_paths) <= 1:
subprocess.run(["black", *python_paths])
else:
logger.warning(
f"this system does not support multiprocessing well, format files one by one ..."
)
[subprocess.run(["black", path]) for path in python_paths]
except subprocess.CalledProcessError as ex:
capture_exception(ex)
logger.error(ex)