Repository: theacodes/nox (python)

Issue:
Some conda commands not logged.
When using `venv_backend="conda"`, the `conda create` command is not logged, even if `-v` is provided, since `log=False` is hard-coded in [`nox/virtualenv.py`](https://github.com/theacodes/nox/blob/master/nox/virtualenv.py#L243):

```python
        nox.command.run(cmd, silent=True, log=False)
```

From the docs, I expected that running `nox -v` would log all commands.

Pull request:
Conda logs now respect nox.options.verbose.
Fixes #345 

First pass at this, I basically just copied the implementation from #371.

Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a73d7b3..59cefcd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,6 +23,28 @@ jobs:
           python -m pip install --disable-pip-version-check .
       - name: Run tests on ${{ matrix.os }}
         run: nox --non-interactive --session "tests-${{ matrix.python-version }}" -- --full-trace
+
+  build-py310:
+    name: Build python 3.10
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-20.04, windows-2019]
+        python-version: ["3.10.0-rc.2"]
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+      # Conda does not support 3.10 yet, hence why it's skipped here
+      # TODO: Merge the two build jobs when 3.10 is released for conda
+      - name: Install Nox-under-test
+        run: |
+          python -m pip install --disable-pip-version-check .
+      - name: Run tests on ${{ matrix.os }}
+        run: nox --non-interactive --session "tests-${{ matrix.python-version }}" -- --full-trace
+
   lint:
     runs-on: ubuntu-20.04
     steps:
diff --git a/nox/sessions.py b/nox/sessions.py
index 0cdbe78..ef20e83 100644
--- a/nox/sessions.py
+++ b/nox/sessions.py
@@ -467,6 +467,20 @@ class Session:
         This method is idempotent; multiple notifications to the same session
         have no effect.
 
+        A common use case is to notify a code coverage analysis session
+        from a test session::
+
+            @nox.session
+            def test(session):
+                session.run("pytest")
+                session.notify("coverage")
+
+            @nox.session
+            def coverage(session):
+                session.run("coverage")
+
+        Now if you run `nox -s test`, the coverage session will run afterwards.
+
         Args:
             target (Union[str, Callable]): The session to be notified. This
                 may be specified as the appropriate string (same as used for
diff --git a/nox/virtualenv.py b/nox/virtualenv.py
index a6bf844..9bf8092 100644
--- a/nox/virtualenv.py
+++ b/nox/virtualenv.py
@@ -22,6 +22,7 @@ from typing import Any, List, Mapping, Optional, Tuple, Union
 
 import py
 
+import nox
 import nox.command
 from nox.logger import logger
 
@@ -250,7 +251,7 @@ class CondaEnv(ProcessEnv):
         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
 
@@ -473,6 +474,6 @@ class VirtualEnv(ProcessEnv):
                 self.location_name,
             )
         )
-        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/noxfile.py b/noxfile.py
index 36150cd..6b31e02 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -30,7 +30,9 @@ def is_python_version(session, version):
     return py_version.startswith(version)
 
 
-@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
+# TODO: When 3.10 is released, change the version below to 3.10
+# this is here so GitHub actions can pick up on the session name
+@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10.0-rc.2"])
 def tests(session):
     """Run test suite with pytest."""
     session.create_tmp()
@@ -103,7 +105,7 @@ def lint(session):
     session.run("flake8", *files)
 
 
-@nox.session(python="3.7")
+@nox.session(python="3.8")
 def docs(session):
     """Build the documentation."""
     output_dir = os.path.join(session.create_tmp(), "output")


Test patch:
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index c85c08b..8fe1c41 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -210,6 +210,23 @@ 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()