@pytest.mark.network
def test_upgrade_if_requested(script):
    script.pip('install', 'INITools==0.1', expect_error=True)
    result = script.pip('install', '--upgrade', 'INITools', expect_error=True)
    assert result.files_created, 'pip install --upgrade did not upgrade'
    assert (
        script.site_packages / 'INITools-0.1-py%s.egg-info' %
        pyversion not in result.files_created
    )
And it does upgrade if requested.
dataset/ETHPy150Open pypa/pip/tests/functional/test_install_upgrade.py/test_upgrade_if_requested