@pytest.mark.network
def test_uninstall_before_upgrade(script):
    result = script.pip('install', 'INITools==0.2', expect_error=True)
    assert script.site_packages / 'initools' in result.files_created, (
        sorted(result.files_created.keys())
    )
    result2 = script.pip('install', 'INITools==0.3', expect_error=True)
    assert result2.files_created, 'upgrade to INITools 0.3 failed'
    result3 = script.pip('uninstall', 'initools', '-y', expect_error=True)
    assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
Automatic uninstall-before-upgrade.
dataset/ETHPy150Open pypa/pip/tests/functional/test_install_upgrade.py/test_uninstall_before_upgrade