From 61dbefeddd65b5d3e742fa9797babd412dc67584 Mon Sep 17 00:00:00 2001 From: Gwyn Date: Sat, 8 May 2021 10:36:04 -0600 Subject: [PATCH] Adds tests for _reused #394 Also reduces verbosity of run_always logging for no_install. --- nox/sessions.py | 1 - nox/virtualenv.py | 5 +++-- tests/test_virtualenv.py | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nox/sessions.py b/nox/sessions.py index 9582d6d1..9250d581 100644 --- a/nox/sessions.py +++ b/nox/sessions.py @@ -291,7 +291,6 @@ def run_always( :type external: bool """ if self._runner.global_config.no_install: - logger.info("Skipping run_always, as --no-install is set.") return None if not args: diff --git a/nox/virtualenv.py b/nox/virtualenv.py index 47a21074..604ee4ee 100644 --- a/nox/virtualenv.py +++ b/nox/virtualenv.py @@ -225,6 +225,7 @@ def create(self) -> bool: logger.debug( "Re-using existing conda env at {}.".format(self.location_name) ) + self._reused = True return False @@ -418,10 +419,10 @@ def create(self) -> bool: self.location_name ) ) - return False - self._reused = False + self._reused = True + return False if self.venv_or_virtualenv == "virtualenv": cmd = [sys.executable, "-m", "virtualenv", self.location] diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py index cb76a877..2804d743 100644 --- a/tests/test_virtualenv.py +++ b/tests/test_virtualenv.py @@ -179,6 +179,7 @@ def test_condaenv_create(make_conda): venv.reuse_existing = True venv.create() assert dir_.join("test.txt").check() + assert venv._reused @pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.") @@ -328,7 +329,10 @@ def test_create(monkeypatch, make_one): assert dir_.join("test.txt").check() venv.reuse_existing = True monkeypatch.setattr(nox.virtualenv.nox.command, "run", mock.MagicMock()) + venv.create() + + assert venv._reused assert dir_.join("test.txt").check()