Skip to content

Commit c265cd4

Browse files
committed
uv-test
1 parent c96ae32 commit c265cd4

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

uv-test

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
# Originally from https://til.simonwillison.net/python/uv-tests
3+
4+
set -eu # (no pipefail in POSIX sh)
5+
6+
usage() {
7+
echo "Usage: uv-test [-p|--python PY_VER] [pytest args...]"
8+
echo " -p, --python Set Python version (default: \$UV_PY or 3.14)"
9+
echo " -h, --help Show this help"
10+
}
11+
12+
PYVER="${UV_PY:-3.14}"
13+
14+
# Parse only our flags; pass the rest to pytest
15+
while [ $# -gt 0 ]; do
16+
case "$1" in
17+
-p|--python)
18+
shift
19+
[ $# -gt 0 ] || { echo "error: -p/--python requires a version" >&2; exit 2; }
20+
PYVER="$1"; shift ;;
21+
-h|--help) usage; exit 0 ;;
22+
--) shift; break ;;
23+
*) break ;;
24+
esac
25+
done
26+
27+
command -v uv >/dev/null 2>&1 || { echo "error: 'uv' not found in PATH" >&2; exit 127; }
28+
if [ ! -f pyproject.toml ] && [ ! -f setup.py ]; then
29+
echo "error: no project file found (need pyproject.toml or setup.py). Run from project root." >&2
30+
exit 1
31+
fi
32+
33+
exec uvx --python "$PYVER" --with pytest --isolated --with-editable . -- pytest "$@"

0 commit comments

Comments
 (0)