Skip to content

Commit

Permalink
Rename refactoring venv_created -> reused. (#394)
Browse files Browse the repository at this point in the history
This was good advice from @cjolowicz helping to clarify the intention
of this boolean.
  • Loading branch information
gwynforthewyn committed Mar 31, 2021
1 parent a9bbab8 commit 4ac9bc1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def conda_install(
raise ValueError("At least one argument required to install().")

if self._runner.global_config.no_install:
if venv._venv_created:
if venv._reused:
logger.info("Skipping conda installation, as --no-install is set.")
return None
else:
Expand Down Expand Up @@ -442,7 +442,7 @@ def install(self, *args: str, **kwargs: Any) -> None:
raise ValueError("At least one argument required to install().")

if self._runner.global_config.no_install:
if venv._venv_created:
if venv._reused:
logger.info("Skipping installation, as --no-install is set.")
return None
else:
Expand Down
6 changes: 3 additions & 3 deletions nox/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ProcessEnv:
def __init__(self, bin_paths: None = None, env: Mapping[str, str] = None) -> None:
self._bin_paths = bin_paths
self.env = os.environ.copy()
self._venv_created = False
self._reused = False

if env is not None:
self.env.update(env)
Expand Down Expand Up @@ -250,7 +250,7 @@ def create(self) -> bool:
)
nox.command.run(cmd, silent=True, log=False)

self._venv_created = True
self._reused = True

return True

Expand Down Expand Up @@ -421,6 +421,6 @@ def create(self) -> bool:
)
nox.command.run(cmd, silent=True, log=False)

self._venv_created = True
self._reused = True

return True
12 changes: 6 additions & 6 deletions tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def test_conda_install(self, auto_offline, offline):
)

@pytest.mark.parametrize(
"no_install,venv_is_created,desired_result",
"no_install,venv_reused,desired_result",
[
(False, False, "Ignoring --no-install"),
(True, False, "Ignoring --no-install"),
Expand All @@ -407,7 +407,7 @@ def test_conda_install(self, auto_offline, offline):
],
)
def test_conda_no_install_with_venv(
self, no_install, venv_is_created, desired_result, caplog
self, no_install, venv_reused, desired_result, caplog
):
caplog.set_level(logging.INFO)
session, runner = self.make_session_and_runner()
Expand All @@ -418,7 +418,7 @@ def test_conda_no_install_with_venv(
runner.venv.is_offline = lambda: True

runner.global_config.no_install = True
runner.venv._venv_created = venv_is_created
runner.venv._reused = venv_reused

with mock.patch.object(nox.command, "run"):
assert session.conda_install("baked beans", "eggs", "spam") is None
Expand Down Expand Up @@ -575,16 +575,16 @@ def test_skip_no_log(self):
session.skip()

@pytest.mark.parametrize(
"no_install,venv_is_created,desired_result",
"no_install,venv_reused,desired_result",
[(True, False, "Venv not created yet"), (True, True, "Skipping")],
)
def test_session_no_install(
self, no_install, venv_is_created, desired_result, caplog
self, no_install, venv_reused, desired_result, caplog
):
caplog.set_level(logging.INFO)
session, runner = self.make_session_and_runner()
runner.global_config.no_install = no_install
runner.venv._venv_created = venv_is_created
runner.venv._reused = venv_reused

with mock.patch.object(nox.command, "run"):
assert session.install("eggs", "spam") is None
Expand Down

0 comments on commit 4ac9bc1

Please sign in to comment.