Skip to content

Commit 7d3ecf6

Browse files
committed
Simplify test_pip_needs_upgrade_mac_os_11
1 parent 6844fb7 commit 7d3ecf6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

tests/test_env.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,18 @@ def test_pip_needs_upgrade_mac_os_11(
126126
mocker.patch('platform.mac_ver', return_value=('11.0', ('', '', ''), arch))
127127
mocker.patch('build._compat.importlib.metadata.distributions', return_value=(SimpleNamespace(version=pip_version),))
128128

129-
min_version = Version('20.3' if arch == 'x86_64' else '21.0.1')
130-
with build.env.DefaultIsolatedEnv():
131-
if Version(pip_version) < min_version:
132-
upgrade_call, uninstall_call = run_subprocess.call_args_list
133-
answer = 'pip>=20.3.0' if arch == 'x86_64' else 'pip>=21.0.1'
134-
assert upgrade_call[0][0][1:] == ['-Im', 'pip', 'install', answer]
135-
assert uninstall_call[0][0][1:] == ['-Im', 'pip', 'uninstall', '-y', 'setuptools']
129+
min_pip_version = '20.3.0' if arch == 'x86_64' else '21.0.1'
130+
131+
with build.env.DefaultIsolatedEnv() as env:
132+
if Version(pip_version) < Version(min_pip_version):
133+
assert run_subprocess.call_args_list == [
134+
mocker.call([env.python_executable, '-Im', 'pip', 'install', f'pip>={min_pip_version}']),
135+
mocker.call([env.python_executable, '-Im', 'pip', 'uninstall', '-y', 'setuptools']),
136+
]
136137
else:
137-
(uninstall_call,) = run_subprocess.call_args_list
138-
assert uninstall_call[0][0][1:] == ['-Im', 'pip', 'uninstall', '-y', 'setuptools']
138+
run_subprocess.assert_called_once_with(
139+
[env.python_executable, '-Im', 'pip', 'uninstall', '-y', 'setuptools'],
140+
)
139141

140142

141143
@pytest.mark.parametrize('has_symlink', [True, False] if sys.platform.startswith('win') else [True])

0 commit comments

Comments
 (0)