Merge pull request #7777 from sinscary/fix_#7249

Raise error if --user and --target arguments are used together
This commit is contained in:
Pradyun Gedam 2020-02-27 11:38:10 -08:00 committed by GitHub
commit 520e76ddb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

1
news/7249.feature Normal file
View File

@ -0,0 +1 @@
Raise error if --user and --target are used together in pip install

View File

@ -237,6 +237,9 @@ class InstallCommand(RequirementCommand):
@with_cleanup
def run(self, options, args):
# type: (Values, List[Any]) -> int
if options.use_user_site and options.target_dir is not None:
raise CommandError("Can not combine '--user' and '--target'")
cmdoptions.check_install_build_global(options)
upgrade_strategy = "to-satisfy-only"
if options.upgrade:

View File

@ -847,6 +847,27 @@ def test_install_package_with_target(script):
assert singlemodule_py in result.files_updated, str(result)
def test_install_package_to_usersite_with_target_must_fail(script):
"""
Test that installing package to usersite with target
must raise error
"""
target_dir = script.scratch_path / 'target'
result = script.pip_install_local(
'--user', '-t', target_dir, "simple==1.0", expect_error=True
)
assert "Can not combine '--user' and '--target'" in result.stderr, (
str(result)
)
result = script.pip_install_local(
'--user', '--target', target_dir, "simple==1.0", expect_error=True
)
assert "Can not combine '--user' and '--target'" in result.stderr, (
str(result)
)
def test_install_nonlocal_compatible_wheel(script, data):
target_dir = script.scratch_path / 'target'