python-pytest-run-capture
Run Python pytest suites and capture reproducible evidence (command, environment, output) into agent-output artifacts. Use for QA verification, debugging, and pre-release confidence.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Skill Instructions
Inputs
-
PYTEST_ARGS(string, optional): e.g.-q,-k test_name,tests/unit -
OUT_DIR(string, optional): output directory (default:agent-output/qa/artifacts) -
STAMP(string, optional): override timestamp (default: auto UTC timestamp)
Procedure
set -euo pipefail
out_dir="${OUT_DIR:-agent-output/qa/artifacts}"
mkdir -p "$out_dir"
stamp="${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)}"
args="${PYTEST_ARGS:-}"
# Capture environment context
{
echo "timestamp_utc=$stamp"
echo "cwd=$(pwd)"
python --version 2>&1 || true
python -c "import sys; print('sys.executable=', sys.executable)" 2>&1 || true
python -c "import platform; print('platform=', platform.platform())" 2>&1 || true
echo "PYTEST_ARGS=$args"
} > "$out_dir/pytest_env_$stamp.txt"
# Run pytest and capture output
set +e
python -m pytest $args > "$out_dir/pytest_out_$stamp.txt" 2>&1
rc=$?
set -e
echo "pytest_exit_code=$rc" | tee "$out_dir/pytest_rc_$stamp.txt"
# Optional: quick summary
sed -n '1,200p' "$out_dir/pytest_out_$stamp.txt" > "$out_dir/pytest_out_head_$stamp.txt" || true
echo "Wrote artifacts to: $out_dir"
exit $rc
Acceptance Criteria
- Output directory contains
pytest_env_*.txt,pytest_out_*.txt, andpytest_rc_*.txt. - Exit code is non-zero on test failure (so pipelines/agents fail fast).
Notes
- Prefer targeted runs first (e.g.,
PYTEST_ARGS=tests/unit -q) before running full suite. - If your project uses a venv/poetry/conda, run pytest via the project’s preferred launcher.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!