-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a hopefully failing test on Windows.
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ include = ["dev_cmd*"] | |
|
||
[dependency-groups] | ||
dev = [ | ||
"ansicolors", | ||
"mypy", | ||
"pytest", | ||
"ruff", | ||
|
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,75 @@ | ||
# Copyright 2025 John Sirois. | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import subprocess | ||
from pathlib import Path, PurePath | ||
from textwrap import dedent | ||
|
||
import colors | ||
import pytest | ||
from pytest import MonkeyPatch | ||
|
||
|
||
@pytest.fixture | ||
def project_dir() -> PurePath: | ||
return PurePath( | ||
subprocess.run( | ||
args=["git", "rev-parse", "--show-toplevel"], | ||
cwd=PurePath(__file__).parent, | ||
stdout=subprocess.PIPE, | ||
text=True, | ||
check=True, | ||
).stdout.strip() | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def pyproject_toml(tmp_path: Path, monkeypatch: MonkeyPatch) -> Path: | ||
monkeypatch.chdir(tmp_path) | ||
return tmp_path / "pyproject.toml" | ||
|
||
|
||
def test_exec_python(tmp_path: Path, pyproject_toml: Path, project_dir: PurePath) -> None: | ||
script = tmp_path / "script.py" | ||
script.write_text( | ||
dedent( | ||
"""\ | ||
import sys | ||
import colors | ||
print(colors.cyan(" ".join(sys.argv[1:]))) | ||
""" | ||
) | ||
) | ||
|
||
pyproject_toml.write_text( | ||
dedent( | ||
f""" | ||
[project] | ||
name = "script-test" | ||
version = "0.1.0" | ||
[dependency-groups] | ||
dev = [ | ||
"ansicolors", | ||
"dev-cmd @ {project_dir}", | ||
] | ||
[tool.dev-cmd.commands.test] | ||
args = ["python", "{script}"] | ||
accepts-extra-args = true | ||
""" | ||
) | ||
) | ||
|
||
assert ( | ||
colors.cyan("Slartibartfast 42") | ||
== subprocess.run( | ||
args=["uv", "run", "dev-cmd", "test", "--", "Slartibartfast", "42"], | ||
stdout=subprocess.PIPE, | ||
text=True, | ||
check=True, | ||
).stdout.strip() | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.