mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 13:29:35 +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
|
# Release History
|
||||||
|
|
||||||
## 3.1.2 (2020-06-23)
|
## 3.1.2 (2020-06-28)
|
||||||
|
|
||||||
**Fixed**
|
**Fixed**
|
||||||
|
|
||||||
- fix: missing setup/teardown hooks for referenced testcase
|
- 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)
|
## 3.1.1 (2020-06-23)
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from httprunner.loader import (
|
|||||||
convert_relative_project_root_dir,
|
convert_relative_project_root_dir,
|
||||||
)
|
)
|
||||||
from httprunner.response import uniform_validator
|
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
|
""" 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:
|
def format_pytest_with_black(*python_paths: Text) -> NoReturn:
|
||||||
logger.info("format pytest cases with black ...")
|
logger.info("format pytest cases with black ...")
|
||||||
try:
|
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:
|
except subprocess.CalledProcessError as ex:
|
||||||
capture_exception(ex)
|
capture_exception(ex)
|
||||||
logger.error(ex)
|
logger.error(ex)
|
||||||
|
|||||||
@@ -4,13 +4,15 @@ import json
|
|||||||
import os.path
|
import os.path
|
||||||
import platform
|
import platform
|
||||||
import uuid
|
import uuid
|
||||||
|
from multiprocessing import Queue
|
||||||
from typing import Dict, List, Any
|
from typing import Dict, List, Any
|
||||||
|
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
from httprunner import __version__
|
from httprunner import __version__
|
||||||
from httprunner import exceptions
|
from httprunner import exceptions
|
||||||
from httprunner.models import VariablesMapping
|
from httprunner.models import VariablesMapping
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
|
|
||||||
def init_sentry_sdk():
|
def init_sentry_sdk():
|
||||||
@@ -209,3 +211,12 @@ def override_config_variables(
|
|||||||
variables = copy.deepcopy(config_variables)
|
variables = copy.deepcopy(config_variables)
|
||||||
variables.update(step_new_variables)
|
variables.update(step_new_variables)
|
||||||
return 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