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()