mirror of https://github.com/pypa/pip
Merge pull request #7777 from sinscary/fix_#7249
Raise error if --user and --target arguments are used together
This commit is contained in:
commit
520e76ddb9
|
@ -0,0 +1 @@
|
|||
Raise error if --user and --target are used together in pip install
|
|
@ -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:
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
Loading…
Reference in New Issue