mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: compatibility for black on Android termux system that does not support multiprocessing
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
# Release History
|
||||
|
||||
## 3.1.2 (2020-06-23)
|
||||
## 3.1.2 (2020-06-28)
|
||||
|
||||
**Fixed**
|
||||
|
||||
- fix: missing setup/teardown hooks for referenced testcase
|
||||
- fix: compatibility for `black` on Android termux that does not support multiprocessing well
|
||||
|
||||
## 3.1.1 (2020-06-23)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,13 +4,15 @@ import json
|
||||
import os.path
|
||||
import platform
|
||||
import uuid
|
||||
from multiprocessing import Queue
|
||||
from typing import Dict, List, Any
|
||||
|
||||
import sentry_sdk
|
||||
from loguru import logger
|
||||
|
||||
from httprunner import __version__
|
||||
from httprunner import exceptions
|
||||
from httprunner.models import VariablesMapping
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def init_sentry_sdk():
|
||||
@@ -209,3 +211,12 @@ def override_config_variables(
|
||||
variables = copy.deepcopy(config_variables)
|
||||
variables.update(step_new_variables)
|
||||
return variables
|
||||
|
||||
|
||||
def is_support_multiprocessing() -> bool:
|
||||
try:
|
||||
Queue()
|
||||
return True
|
||||
except (ImportError, OSError):
|
||||
# system that does not support semaphores(dependency of multiprocessing), like Android termux
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user