Skip to content

Commit 6a67f96

Browse files
committed
Add failing tests for issue pypa#1139 re: --force-reinstall.
1 parent 744c64e commit 6a67f96

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import pytest
2+
3+
from tests.lib import assert_all_changes, pyversion_tuple
4+
5+
6+
def check_installed_version(script, package, expected):
7+
# Python 3.3 emits a "Python 3.3 support has been deprecated" warning.
8+
expect_stderr = (pyversion_tuple[:2] == (3, 3))
9+
result = script.run('pip', 'show', package, expect_stderr=expect_stderr)
10+
lines = result.stdout.splitlines()
11+
for line in lines:
12+
if line.startswith('Version: '):
13+
version = line.split()[-1]
14+
break
15+
assert version == expected, 'version {} != {}'.format(version, expected)
16+
17+
18+
@pytest.mark.network
19+
def test_force_reinstall_with_no_version_specifier(script):
20+
"""
21+
Check --force-reinstall when there is no version specifier and the
22+
installed version is not the newest version.
23+
"""
24+
result = script.pip('install', 'INITools==0.2')
25+
check_installed_version(script, 'initools', '0.2')
26+
result2 = script.pip('install', '--force-reinstall', 'INITools')
27+
assert result2.files_updated, 'force-reinstall failed'
28+
check_installed_version(script, 'initools', '0.3.1')
29+
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True)
30+
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
31+
32+
33+
@pytest.mark.network
34+
def test_force_reinstall_with_same_version_specifier(script):
35+
"""
36+
Check --force-reinstall when the version specifier equals the installed
37+
version and the installed version is not the newest version.
38+
"""
39+
result = script.pip('install', 'INITools==0.2')
40+
check_installed_version(script, 'initools', '0.2')
41+
result2 = script.pip('install', '--force-reinstall', 'INITools==0.2')
42+
assert result2.files_updated, 'force-reinstall failed'
43+
check_installed_version(script, 'initools', '0.2')
44+
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True)
45+
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])

0 commit comments

Comments
 (0)