Skip to content

Commit

Permalink
tests: verify correction works
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Apr 12, 2024
1 parent 90c62b0 commit 9d21506
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import nox.virtualenv
from nox._decorators import Func
from nox.logger import logger
from nox.virtualenv import UV, CondaEnv, PassthroughEnv, ProcessEnv, VirtualEnv
from nox.virtualenv import CondaEnv, PassthroughEnv, ProcessEnv, VirtualEnv

if TYPE_CHECKING:
from nox.manifest import Manifest
Expand Down Expand Up @@ -500,8 +500,8 @@ def _run(
return self._run_func(args[0], args[1:], kwargs) # type: ignore[unreachable]

# Using `"uv"` when `uv` is the backend is guaranteed to work, even if it was co-installed with nox.
if self.virtualenv.venv_backend == "uv" and args[0] == "uv" and UV != "uv":
args = (UV, *args[1:])
if self.virtualenv.venv_backend == "uv" and args[0] == "uv" and nox.virtualenv.UV != "uv":
args = (nox.virualenv.UV, *args[1:])

# Combine the env argument with our virtualenv's env vars.
if include_outer_env:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ def test_session_venv_reused_with_no_install(self, no_install, reused, run_calle

assert run.called is run_called

def test_install_uv(self):
@pytest.mark.parametrize("uv", [None, "/some/uv"])
def test_install_uv(self, uv, monkeypatch):
runner = nox.sessions.SessionRunner(
name="test",
signatures=["test"],
Expand All @@ -840,6 +841,9 @@ class SessionNoSlots(nox.sessions.Session):

session = SessionNoSlots(runner=runner)

if uv is not None:
monkeypatch.setattr(nox.virtualenv, "UV", uv)

with mock.patch.object(session, "_run", autospec=True) as run:
session.install("requests", "urllib3", silent=False)
run.assert_called_once_with(
Expand Down

0 comments on commit 9d21506

Please sign in to comment.