Merge pull request #7588 from uranusjr/reinstall-test

Delete a file to let --force-reinstall fix it
This commit is contained in:
Christopher Hunt 2020-01-15 11:48:27 +08:00 committed by GitHub
commit f2bb7c4e57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

0
news/7587.trivial Normal file
View File

View File

@ -1,3 +1,4 @@
import os
from tests.lib import assert_all_changes
@ -22,10 +23,18 @@ def check_force_reinstall(script, specifier, expected):
result = script.pip_install_local('simplewheel==1.0')
check_installed_version(script, 'simplewheel', '1.0')
# Remove an installed file to test whether --force-reinstall fixes it.
to_fix = script.site_packages_path.joinpath("simplewheel", "__init__.py")
to_fix.unlink()
result2 = script.pip_install_local('--force-reinstall', specifier)
assert result2.files_updated, 'force-reinstall failed'
check_installed_version(script, 'simplewheel', expected)
# site_packages_path is absolute, but files_created mapping uses
# relative paths as key.
fixed_key = os.path.relpath(to_fix, script.base_path)
assert fixed_key in result2.files_created, 'force-reinstall failed'
result3 = script.pip('uninstall', 'simplewheel', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])