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

fix: nox.session.run-ing commands with pathlib.Path arguments #649

Merged
merged 2 commits into from
Oct 7, 2022
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
3 changes: 1 addition & 2 deletions nox/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ def _clean_env(env: dict[str, str] | None) -> dict[str, str] | None:


def _shlex_join(args: Sequence[str]) -> str:
# shlex.join() was added in Python 3.8
return " ".join(shlex.quote(arg) for arg in args)
return " ".join(shlex.quote(os.fspath(arg)) for arg in args)


def run(
Expand Down
14 changes: 14 additions & 0 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import subprocess
import sys
import time
from pathlib import Path
from textwrap import dedent
from unittest import mock

Expand Down Expand Up @@ -112,6 +113,19 @@ def test_run_verbosity_failed_command(capsys, caplog):
assert not logs


@pytest.mark.skipif(
platform.system() == "Windows",
reason="See https://github.com/python/cpython/issues/85815",
)
def test_run_non_str():
result = nox.command.run(
[Path(PYTHON), "-c", "import sys; print(sys.argv)", Path(PYTHON)],
silent=True,
)

assert PYTHON in result


def test_run_env_unicode():
result = nox.command.run(
[PYTHON, "-c", 'import os; print(os.environ["SIGIL"])'],
Expand Down