installer.py: require "explicit: True" in the install arguments to mark a package "explicit" (#31646)

This commit is contained in:
Harmen Stoppels 2022-07-20 12:09:45 +02:00 committed by GitHub
parent 43673fee80
commit e3aca44601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -2212,7 +2212,8 @@ def flag_installed(self, installed):
@property
def explicit(self):
"""The package was explicitly requested by the user."""
return self.pkg == self.request.pkg
return self.pkg == self.request.pkg and \
self.request.install_args.get('explicit', True)
@property
def key(self):

View File

@ -1176,6 +1176,18 @@ def test_install_skip_patch(install_mockery, mock_fetch):
assert inst.package_id(spec.package) in installer.installed
def test_install_implicit(install_mockery, mock_fetch):
"""Test the path skip_patch install path."""
spec_name = 'trivial-install-test-package'
const_arg = installer_args([spec_name],
{'fake': False})
installer = create_installer(const_arg)
pkg = installer.build_requests[0].pkg
assert not create_build_task(pkg, {'explicit': False}).explicit
assert create_build_task(pkg, {'explicit': True}).explicit
assert create_build_task(pkg).explicit
def test_overwrite_install_backup_success(temporary_store, config, mock_packages,
tmpdir):
"""