|
14 | 14 |
|
15 | 15 | from __future__ import annotations |
16 | 16 |
|
| 17 | +import functools |
17 | 18 | import os |
18 | 19 | import re |
19 | 20 | import shutil |
@@ -52,14 +53,13 @@ class TextProcessResult(NamedTuple): |
52 | 53 | def make_one(tmpdir): |
53 | 54 | def factory(*args, venv_backend: str = "virtualenv", **kwargs): |
54 | 55 | location = tmpdir.join("venv") |
55 | | - if venv_backend in {"mamba", "conda"}: |
56 | | - venv = nox.virtualenv.CondaEnv( |
57 | | - location.strpath, *args, conda_cmd=venv_backend, **kwargs |
58 | | - ) |
59 | | - else: |
60 | | - venv = nox.virtualenv.VirtualEnv( |
61 | | - location.strpath, *args, venv_backend=venv_backend, **kwargs |
| 56 | + try: |
| 57 | + venv_fn = nox.virtualenv.ALL_VENVS[venv_backend] |
| 58 | + except KeyError: |
| 59 | + venv_fn = functools.partial( |
| 60 | + nox.virtualenv.VirtualEnv, venv_backend=venv_backend |
62 | 61 | ) |
| 62 | + venv = venv_fn(location.strpath, *args, **kwargs) |
63 | 63 | return (venv, location) |
64 | 64 |
|
65 | 65 | return factory |
@@ -490,13 +490,21 @@ def test_stale_environment(make_one, frm, to, result, monkeypatch): |
490 | 490 | monkeypatch.setenv("NOX_ENABLE_STALENESS_CHECK", "1") |
491 | 491 | venv, _ = make_one(reuse_existing=True, venv_backend=frm) |
492 | 492 | venv.create() |
| 493 | + assert venv.venv_backend == frm |
493 | 494 |
|
494 | 495 | venv, _ = make_one(reuse_existing=True, venv_backend=to) |
495 | 496 | reused = venv._check_reused_environment_type() |
| 497 | + assert venv.venv_backend == to |
496 | 498 |
|
497 | 499 | assert reused == result |
498 | 500 |
|
499 | 501 |
|
| 502 | +def test_passthrough_environment_venv_backend(make_one): |
| 503 | + venv, _ = make_one(venv_backend="none") |
| 504 | + venv.create() |
| 505 | + assert venv.venv_backend == "none" |
| 506 | + |
| 507 | + |
500 | 508 | @has_uv |
501 | 509 | def test_create_reuse_stale_virtualenv_environment(make_one, monkeypatch): |
502 | 510 | monkeypatch.setenv("NOX_ENABLE_STALENESS_CHECK", "1") |
|
0 commit comments