Skip to content

Commit e01ad52

Browse files
committed
Update tests
1 parent 2e65e58 commit e01ad52

File tree

3 files changed

+18
-34
lines changed

3 files changed

+18
-34
lines changed

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ def tmp_dir():
127127
shutil.rmtree(path)
128128

129129

130-
@pytest.fixture(autouse=True)
131-
def force_venv(mocker):
132-
mocker.patch.object(build.env, '_has_virtualenv', lambda: False)
130+
@pytest.fixture(autouse=True, params=[False])
131+
def has_virtualenv(request, mocker):
132+
mocker.patch.object(build.env, '_has_virtualenv', lambda: request.param)
133133

134134

135135
def pytest_report_header() -> str:

tests/test_env.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_isolated_env_log(
9797
env.install(['something'])
9898

9999
assert [(record.levelname, record.message) for record in caplog.records] == [
100-
('INFO', 'Creating isolated environment: venv...'),
100+
('INFO', 'Creating isolated environment: venv+pip...'),
101101
('INFO', 'Installing packages in isolated environment:\n- something'),
102102
]
103103

@@ -197,27 +197,10 @@ def test_venv_or_virtualenv_impl_install_cmd_well_formed(
197197
]
198198

199199

200-
@pytest.mark.parametrize('verbosity', [0, 1, 9000])
201-
def test_uv_impl_create_cmd_well_formed(
202-
mocker: pytest_mock.MockerFixture,
203-
verbosity: int,
204-
):
205-
run_subprocess = mocker.patch('build.env.run_subprocess')
206-
207-
with pytest.raises(RuntimeError, match='Virtual environment creation failed'), \
208-
build.env.DefaultIsolatedEnv('uv') as env: # fmt: skip
209-
(create_call,) = run_subprocess.call_args_list
210-
cmd_tail = ['venv', env.path]
211-
if verbosity:
212-
cmd_tail += ['-v']
213-
assert create_call.args[0][1:] == cmd_tail
214-
assert not create_call.kwargs
215-
216-
217200
def test_uv_impl_install_cmd_well_formed(
218201
mocker: pytest_mock.MockerFixture,
219202
):
220-
with build.env.DefaultIsolatedEnv('uv') as env:
203+
with build.env.DefaultIsolatedEnv('venv+uv') as env:
221204
run_subprocess = mocker.patch('build.env.run_subprocess')
222205

223206
env.install(['foo'])
@@ -230,15 +213,16 @@ def test_uv_impl_install_cmd_well_formed(
230213

231214

232215
@pytest.mark.parametrize(
233-
('env_impl', 'backend_cls'),
216+
('env_impl', 'backend_cls', 'has_virtualenv'),
234217
[
235-
('venv', build.env._VenvImplBackend),
236-
('virtualenv', build.env._VirtualenvImplBackend),
237-
('uv', build.env._UvImplBackend),
218+
(None, build.env._VenvImplBackend, False),
219+
(None, build.env._VirtualenvImplBackend, True),
220+
('venv+uv', build.env._UvImplBackend, None),
238221
],
222+
indirect=('has_virtualenv',),
239223
)
240-
def test_venv_creation(
241-
env_impl: build.env.EnvImpl,
224+
def test_uv_venv_creation(
225+
env_impl: build.env.EnvImpl | None,
242226
backend_cls: build.env._EnvImplBackend,
243227
):
244228
with build.env.DefaultIsolatedEnv(env_impl) as env:

tests/test_main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu
236236
pytest.param(
237237
[],
238238
[
239-
'* Creating isolated environment: venv...',
239+
'* Creating isolated environment: venv+pip...',
240240
'* Installing packages in isolated environment:',
241241
' - setuptools >= 42.0.0',
242242
'* Getting build dependencies for sdist...',
243243
'* Building sdist...',
244244
'* Building wheel from sdist',
245-
'* Creating isolated environment: venv...',
245+
'* Creating isolated environment: venv+pip...',
246246
'* Installing packages in isolated environment:',
247247
' - setuptools >= 42.0.0',
248248
'* Getting build dependencies for wheel...',
@@ -269,7 +269,7 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu
269269
pytest.param(
270270
['--wheel'],
271271
[
272-
'* Creating isolated environment: venv...',
272+
'* Creating isolated environment: venv+pip...',
273273
'* Installing packages in isolated environment:',
274274
' - setuptools >= 42.0.0',
275275
'* Getting build dependencies for wheel...',
@@ -327,7 +327,7 @@ def test_output(package_test_setuptools, tmp_dir, capsys, args, output):
327327
False,
328328
'ERROR ',
329329
[
330-
'* Creating isolated environment: venv...',
330+
'* Creating isolated environment: venv+pip...',
331331
'* Installing packages in isolated environment:',
332332
' - setuptools >= 42.0.0',
333333
' - this is invalid',
@@ -337,7 +337,7 @@ def test_output(package_test_setuptools, tmp_dir, capsys, args, output):
337337
True,
338338
'\33[91mERROR\33[0m ',
339339
[
340-
'\33[1m* Creating isolated environment: venv...\33[0m',
340+
'\33[1m* Creating isolated environment: venv+pip...\33[0m',
341341
'\33[1m* Installing packages in isolated environment:\33[0m',
342342
' - setuptools >= 42.0.0',
343343
' - this is invalid',
@@ -429,7 +429,7 @@ def raise_called_process_err(*args, **kwargs):
429429
assert (
430430
stdout
431431
== """\
432-
* Creating isolated environment: venv...
432+
* Creating isolated environment: venv+pip...
433433
> test args
434434
< stdoutput
435435
ERROR Failed to create venv. Maybe try installing virtualenv.

0 commit comments

Comments
 (0)