Skip to content

Commit

Permalink
Enable logging for creation of conda envs if verbose option is set. w…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolker-KU committed Dec 20, 2020
1 parent a188be7 commit f54a2b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nox/virtualenv.py
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions tests/test_virtualenv.py
Expand Up @@ -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()
Expand Down

0 comments on commit f54a2b5

Please sign in to comment.