From f54a2b554064e82720f3173696ec37de1f51b777 Mon Sep 17 00:00:00 2001 From: Tolker-KU Date: Sun, 20 Dec 2020 10:27:49 +0100 Subject: [PATCH] Enable logging for creation of conda envs if verbose option is set. https://github.com/theacodes/nox/issues/345. --- nox/virtualenv.py | 3 ++- tests/test_virtualenv.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nox/virtualenv.py b/nox/virtualenv.py index 4a086e0f..82ba183f 100644 --- a/nox/virtualenv.py +++ b/nox/virtualenv.py @@ -20,6 +20,7 @@ from socket import gethostbyname from typing import Any, List, Mapping, Optional, Tuple, Union +import nox import nox.command import py from nox.logger import logger @@ -240,7 +241,7 @@ def create(self) -> bool: logger.info( "Creating conda env in {} with {}".format(self.location_name, python_dep) ) - nox.command.run(cmd, silent=True, log=False) + nox.command.run(cmd, silent=True, log=nox.options.verbose or False) return True diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py index eb67694a..bb3b5f11 100644 --- a/tests/test_virtualenv.py +++ b/tests/test_virtualenv.py @@ -183,6 +183,21 @@ def test_condaenv_create_interpreter(make_conda): assert dir_.join("bin", "python3.7").check() +@pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.") +def test_conda_env_create_verbose(make_conda): + venv, dir_ = make_conda() + with mock.patch("nox.virtualenv.nox.command.run") as mock_run: + venv.create() + args, kwargs = mock_run.call_args + assert kwargs["log"] is False + + nox.options.verbose = True + with mock.patch("nox.virtualenv.nox.command.run") as mock_run: + venv.create() + args, kwargs = mock_run.call_args + assert kwargs["log"] + + @mock.patch("nox.virtualenv._SYSTEM", new="Windows") def test_condaenv_bin_windows(make_conda): venv, dir_ = make_conda()