Skip to content

Commit

Permalink
Add a hopefully failing test on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Jan 5, 2025
1 parent 14e0fd0 commit 870787e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ include = ["dev_cmd*"]

[dependency-groups]
dev = [
"ansicolors",
"mypy",
"pytest",
"ruff",
Expand Down
75 changes: 75 additions & 0 deletions tests/test_exec.py
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()
)
2 changes: 2 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 870787e

Please sign in to comment.