Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow silent argument to be set in session.install #157

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,10 @@ def install(self, *args, **kwargs):
if not args:
raise ValueError("At least one argument required to install().")

self.run(
"pip",
"install",
"--upgrade",
*args,
silent=True,
external="error",
**kwargs
)
if "silent" not in kwargs:
kwargs["silent"] = True

self.run("pip", "install", "--upgrade", *args, external="error", **kwargs)

def notify(self, target):
"""Place the given session at the end of the queue.
Expand Down
28 changes: 28 additions & 0 deletions tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,34 @@ class SessionNoSlots(nox.sessions.Session):
external="error",
)

def test_install_non_default_kwargs(self):
runner = nox.sessions.SessionRunner(
name="test",
signatures=["test"],
func=mock.sentinel.func,
global_config=argparse.Namespace(posargs=mock.sentinel.posargs),
manifest=mock.create_autospec(nox.manifest.Manifest),
)
runner.venv = mock.create_autospec(nox.virtualenv.VirtualEnv)
runner.venv.env = {}

class SessionNoSlots(nox.sessions.Session):
pass

session = SessionNoSlots(runner=runner)

with mock.patch.object(session, "run", autospec=True) as run:
session.install("requests", "urllib3", silent=False)
run.assert_called_once_with(
"pip",
"install",
"--upgrade",
"requests",
"urllib3",
silent=False,
external="error",
)

def test_notify(self):
session, runner = self.make_session_and_runner()

Expand Down