Return int status code from download.run

This commit is contained in:
Devesh Kumar Singh 2020-05-22 00:32:37 +05:30
parent 197bbceed1
commit 716a067335
2 changed files with 7 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import os
from pip._internal.cli import cmdoptions
from pip._internal.cli.cmdoptions import make_target_python
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.req.req_tracker import get_requirement_tracker
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
from pip._internal.utils.temp_dir import TempDirectory
@ -14,7 +15,6 @@ from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import Any, List
from pip._internal.req.req_set import RequirementSet
logger = logging.getLogger(__name__)
@ -81,7 +81,7 @@ class DownloadCommand(RequirementCommand):
@with_cleanup
def run(self, options, args):
# type: (Values, List[str]) -> RequirementSet
# type: (Values, List[str]) -> int
options.ignore_installed = True
# editable doesn't really make sense for `pip download`, but the bowels
@ -144,5 +144,6 @@ class DownloadCommand(RequirementCommand):
])
if downloaded:
write_output('Successfully downloaded %s', downloaded)
return SUCCESS
return requirement_set
return ERROR

View File

@ -666,7 +666,9 @@ def test_download_exit_status_code_when_blank_requirements_file(script):
Test download exit status code when blank requirements file specified
"""
script.scratch_path.joinpath("blank.txt").write_text("\n")
script.pip('download', '-r', 'blank.txt')
result = script.pip('download', '-r', 'blank.txt', expect_error=True)
print(result)
assert result.returncode == ERROR
def test_download_prefer_binary_when_tarball_higher_than_wheel(script, data):