-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> fix: version based on pipx Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> fix: subprocess on Windows Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> fix: uv or virtualenv, test Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> fix: windows Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> fix: ignore errors in rmtree (3.8+ should be fine on Windows now) fix: resolve nox path on Windows Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
- Loading branch information
Showing
8 changed files
with
254 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# /// script | ||
# dependencies = ["nox", "cowsay"] | ||
# /// | ||
|
||
import cowsay | ||
|
||
import nox | ||
|
||
|
||
@nox.session | ||
def example(session: nox.Session) -> None: | ||
print(cowsay.cow("hello_world")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import importlib.metadata | ||
import importlib.util | ||
import sys | ||
|
||
import packaging.requirements | ||
import packaging.version | ||
import pytest | ||
|
||
import nox._cli | ||
|
||
|
||
def test_get_dependencies(): | ||
if importlib.util.find_spec("tox") is None: | ||
with pytest.raises(ModuleNotFoundError): | ||
list( | ||
nox._cli.get_dependencies( | ||
packaging.requirements.Requirement("nox[tox_to_nox]") | ||
) | ||
) | ||
else: | ||
deps = nox._cli.get_dependencies( | ||
packaging.requirements.Requirement("nox[tox_to_nox]") | ||
) | ||
dep_list = { | ||
"nox", | ||
"argcomplete", | ||
"colorlog", | ||
"dependency-groups", | ||
"packaging", | ||
"virtualenv", | ||
"jinja2", | ||
"tox", | ||
} | ||
if sys.version_info < (3, 11): | ||
dep_list.add("tomli") | ||
assert {d.name for d in deps} == dep_list | ||
|
||
|
||
def test_version_check(): | ||
current_version = packaging.version.Version(importlib.metadata.version("nox")) | ||
|
||
assert nox._cli.check_dependencies([f"nox>={current_version}"]) | ||
assert not nox._cli.check_dependencies([f"nox>{current_version}"]) | ||
|
||
plus_one = packaging.version.Version( | ||
f"{current_version.major}.{current_version.minor}.{current_version.micro+1}" | ||
) | ||
assert not nox._cli.check_dependencies([f"nox>={plus_one}"]) | ||
|
||
|
||
def test_nox_check(): | ||
with pytest.raises(ValueError, match="Must have a nox"): | ||
nox._cli.check_dependencies(["packaging"]) | ||
|
||
with pytest.raises(ValueError, match="Must have a nox"): | ||
nox._cli.check_dependencies([]) | ||
|
||
|
||
def test_unmatched_specifier(): | ||
assert not nox._cli.check_dependencies(["packaging<1", "nox"]) | ||
|
||
|
||
def test_invalid_mode(monkeypatch: pytest.MonkeyPatch): | ||
monkeypatch.setenv("NOX_SCRIPT_MODE", "invalid") | ||
monkeypatch.setattr(sys, "argv", ["nox"]) | ||
|
||
with pytest.raises(SystemExit, match="Invalid NOX_SCRIPT_MODE"): | ||
nox._cli.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters