diff --git a/news/7587.trivial b/news/7587.trivial new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/test_install_force_reinstall.py b/tests/functional/test_install_force_reinstall.py index 56c7aee39..c312ac79f 100644 --- a/tests/functional/test_install_force_reinstall.py +++ b/tests/functional/test_install_force_reinstall.py @@ -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'])