mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:59:44 +08:00
fix: ensure upload ready
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
|
||||
- feat: implement step setup/teardown hooks
|
||||
|
||||
**Fixed**
|
||||
|
||||
- fix: ensure upload ready
|
||||
|
||||
## 3.0.9 (2020-06-07)
|
||||
|
||||
**Fixed**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
__version__ = "3.0.9"
|
||||
__version__ = "3.0.10"
|
||||
__description__ = "One-stop solution for HTTP(S) testing."
|
||||
|
||||
from httprunner.runner import HttpRunner
|
||||
|
||||
@@ -60,6 +60,22 @@ except ModuleNotFoundError:
|
||||
UPLOAD_READY = False
|
||||
|
||||
|
||||
def ensure_upload_ready():
|
||||
if UPLOAD_READY:
|
||||
return
|
||||
|
||||
msg = """
|
||||
uploader extension dependencies uninstalled, install first and try again.
|
||||
install with pip:
|
||||
$ pip install requests_toolbelt filetype
|
||||
|
||||
or you can install httprunner with optional upload dependencies:
|
||||
$ pip install "httprunner[upload]"
|
||||
"""
|
||||
logger.error(msg)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def prepare_upload_step(step: TStep, functions: FunctionsMapping) -> "NoReturn":
|
||||
""" preprocess for upload test
|
||||
replace `upload` info with MultipartEncoder
|
||||
@@ -86,15 +102,7 @@ def prepare_upload_step(step: TStep, functions: FunctionsMapping) -> "NoReturn":
|
||||
if not step.request.upload:
|
||||
return
|
||||
|
||||
if not UPLOAD_READY:
|
||||
msg = """
|
||||
uploader extension dependencies uninstalled, install first and try again.
|
||||
install with pip:
|
||||
$ pip install requests_toolbelt filetype
|
||||
"""
|
||||
logger.error(msg)
|
||||
sys.exit(1)
|
||||
|
||||
ensure_upload_ready()
|
||||
params_list = []
|
||||
for key, value in step.request.upload.items():
|
||||
step.variables[key] = value
|
||||
@@ -126,6 +134,7 @@ def multipart_encoder(**kwargs):
|
||||
else:
|
||||
return "text/html"
|
||||
|
||||
ensure_upload_ready()
|
||||
fields_dict = {}
|
||||
for key, value in kwargs.items():
|
||||
|
||||
@@ -165,4 +174,5 @@ def multipart_content_type(m_encoder) -> Text:
|
||||
content type
|
||||
|
||||
"""
|
||||
ensure_upload_ready()
|
||||
return m_encoder.content_type
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "httprunner"
|
||||
version = "3.0.9"
|
||||
version = "3.0.10"
|
||||
description = "One-stop solution for HTTP(S) testing."
|
||||
license = "Apache-2.0"
|
||||
readme = "README.md"
|
||||
@@ -44,8 +44,8 @@ requests-toolbelt = {version = "^0.9.1", optional = true}
|
||||
filetype = {version = "^1.0.7", optional = true}
|
||||
|
||||
[tool.poetry.extras]
|
||||
allure = ["allure-pytest"] # poetry install -E allure
|
||||
upload = ["requests-toolbelt", "filetype"] # poetry install -E upload
|
||||
allure = ["allure-pytest"] # pip install "httprunner[allure]", poetry install -E allure
|
||||
upload = ["requests-toolbelt", "filetype"] # pip install "httprunner[upload]", poetry install -E upload
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
coverage = "^4.5.4"
|
||||
|
||||
Reference in New Issue
Block a user