diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d5a4b732..1d8c8f18 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.4.2 (2019-12-13) + +**Changed** + +- refactor: replace with open file handler, avoid reading files into memory + ## 2.4.1 (2019-12-12) **Added** diff --git a/httprunner/__init__.py b/httprunner/__init__.py index ef6aac10..8be0e197 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.4.1" +__version__ = "2.4.2" __description__ = "One-stop solution for HTTP(S) testing." __all__ = ["__version__", "__description__"] diff --git a/httprunner/ext/uploader/__init__.py b/httprunner/ext/uploader/__init__.py index 404d635b..fb299b1d 100644 --- a/httprunner/ext/uploader/__init__.py +++ b/httprunner/ext/uploader/__init__.py @@ -128,9 +128,10 @@ def multipart_encoder(**kwargs): if is_exists_file: # value is file path to upload filename = os.path.basename(_file_path) - with open(_file_path, 'rb') as f: - mime_type = get_filetype(_file_path) - fields_dict[key] = (filename, f.read(), mime_type) + mime_type = get_filetype(_file_path) + # TODO: fix ResourceWarning for unclosed file + file_handler = open(_file_path, 'rb') + fields_dict[key] = (filename, file_handler, mime_type) else: fields_dict[key] = value diff --git a/pyproject.toml b/pyproject.toml index 168a025b..3bbc6e33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "httprunner" -version = "2.4.1" +version = "2.4.2" description = "One-stop solution for HTTP(S) testing." license = "Apache-2.0" readme = "README.md"