Skip to content

Expected 'uv_install_python' to be called once. Called 0 times. #1046

@mtelka

Description

@mtelka

Following two tests are failing. I suspect the reason is that there is no uv installed on this platform (and it cannot be installed using pip install uv):

________________ test_download_python_failed_install[always-uv] ________________
    
uv_install_mock = <MagicMock name='uv_install_python' id='140736105955136'>
pbs_install_mock = <MagicMock name='pbs_install_python' id='140736093799568'>
download_python = 'always', venv_backend = 'uv'
make_one = <function make_one.<locals>.factory at 0x7ffface031f0>
        
    @pytest.mark.parametrize("venv_backend", ["uv", "venv", "virtualenv"])
    @pytest.mark.parametrize("download_python", ["always", "auto"])
    @mock.patch("nox.virtualenv.pbs_install_python", return_value=None)
    @mock.patch("nox.virtualenv.uv_install_python", return_value=False)
    def test_download_python_failed_install(
        uv_install_mock: mock.Mock,
        pbs_install_mock: mock.Mock,
        download_python: str,
        venv_backend: str,
        make_one: Callable[..., tuple[VirtualEnv, Path]],
    ) -> None:
        venv, _ = make_one(
            interpreter="python3.11",
            venv_backend=venv_backend,
            download_python=download_python,
        )
        
        with mock.patch.object(shutil, "which", return_value=None) as _, pytest.raises(
            nox.virtualenv.InterpreterNotFound
        ):
            _ = venv._resolved_interpreter

        if venv_backend == "uv":
>           uv_install_mock.assert_called_once_with("python3.11")

tests/test_virtualenv.py:1533:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
        
self = <MagicMock name='uv_install_python' id='140736105955136'>
args = ('python3.11',), kwargs = {}
msg = "Expected 'uv_install_python' to be called once. Called 0 times."
                   
    def assert_called_once_with(self, /, *args, **kwargs):
        """assert that the mock was called exactly once and that that call was
        with the specified arguments."""
        if not self.call_count == 1: 
            msg = ("Expected '%s' to be called once. Called %s times.%s"
                   % (self._mock_name or 'mock',
                      self.call_count,
                      self._calls_repr()))
>           raise AssertionError(msg)
E           AssertionError: Expected 'uv_install_python' to be called once. Called 0 times.

/usr/lib/python3.9/unittest/mock.py:918: AssertionError
_________________ test_download_python_failed_install[auto-uv] _________________

uv_install_mock = <MagicMock name='uv_install_python' id='140736093610288'>
pbs_install_mock = <MagicMock name='pbs_install_python' id='140736093656688'>
download_python = 'auto', venv_backend = 'uv'
make_one = <function make_one.<locals>.factory at 0x7fffacdc4ee0>

    @pytest.mark.parametrize("venv_backend", ["uv", "venv", "virtualenv"])
    @pytest.mark.parametrize("download_python", ["always", "auto"])
    @mock.patch("nox.virtualenv.pbs_install_python", return_value=None)
    @mock.patch("nox.virtualenv.uv_install_python", return_value=False)
    def test_download_python_failed_install(
        uv_install_mock: mock.Mock,
        pbs_install_mock: mock.Mock,
        download_python: str,
        venv_backend: str,
        make_one: Callable[..., tuple[VirtualEnv, Path]],
    ) -> None:
        venv, _ = make_one(
            interpreter="python3.11",
            venv_backend=venv_backend,
            download_python=download_python,
        )

        with mock.patch.object(shutil, "which", return_value=None) as _, pytest.raises(
            nox.virtualenv.InterpreterNotFound
        ):
            _ = venv._resolved_interpreter

        if venv_backend == "uv":
>           uv_install_mock.assert_called_once_with("python3.11")

tests/test_virtualenv.py:1533:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <MagicMock name='uv_install_python' id='140736093610288'>
args = ('python3.11',), kwargs = {}
msg = "Expected 'uv_install_python' to be called once. Called 0 times."

    def assert_called_once_with(self, /, *args, **kwargs):
        """assert that the mock was called exactly once and that that call was
        with the specified arguments."""
        if not self.call_count == 1:
            msg = ("Expected '%s' to be called once. Called %s times.%s"
                   % (self._mock_name or 'mock',
                      self.call_count,
                      self._calls_repr()))
>           raise AssertionError(msg)
E           AssertionError: Expected 'uv_install_python' to be called once. Called 0 times.

/usr/lib/python3.9/unittest/mock.py:918: AssertionError

OS: OpenIndiana
nox: 2025.11.12
Python: 3.14.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions