Skip to content

Commit

Permalink
Adds tests for _reused #394
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynforthewyn committed May 8, 2021
1 parent 6ac8898 commit 5498014
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nox/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions tests/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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()


Expand Down

0 comments on commit 5498014

Please sign in to comment.