Skip to content

Commit

Permalink
Add test case for using --pythons with nox.options.sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
cjolowicz committed Nov 13, 2020
1 parent c0ece7d commit 272cb25
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,37 @@ def generate_noxfile(default_session, default_python, alternate_python):
return generate_noxfile


python_current_version = "{}.{}".format(sys.version_info.major, sys.version_info.minor)
python_next_version = "{}.{}".format(sys.version_info.major, sys.version_info.minor + 1)


def test_main_noxfile_options_with_pythons_override(
capsys, monkeypatch, generate_noxfile_options_pythons
):
noxfile = generate_noxfile_options_pythons(
default_session="test",
default_python=python_next_version,
alternate_python=python_current_version,
)

monkeypatch.setattr(
sys, "argv", ["nox", "--noxfile", noxfile, "--python", python_current_version]
)

with mock.patch("sys.exit") as sys_exit:
nox.__main__.main()
_, stderr = capsys.readouterr()
sys_exit.assert_called_once_with(0)

for python_version in [python_current_version, python_next_version]:
for session in ["test", "launch_rocket"]:
line = "Running session {}-{}".format(session, python_version)
if session == "test" and python_version == python_current_version:
assert line in stderr
else:
assert line not in stderr


@pytest.mark.parametrize(("isatty_value", "expected"), [(True, True), (False, False)])
def test_main_color_from_isatty(monkeypatch, isatty_value, expected):
monkeypatch.setattr(sys, "argv", [sys.executable])
Expand Down

0 comments on commit 272cb25

Please sign in to comment.