python-pytest-ops skill
scriptsfixture, parametrization, 예외 처리 및 mocking을 포함한 현대적인 Python 테스트 패턴을 구현합니다.
- GitHub 스타
- 81
- 파일
- 12
- 마지막 커밋
- 2026년 11월 7일
- 라이선스
- MIT
- 허용된 도구
- 3
python-pytest-ops skill은 무엇을 하나요?
python-pytest-ops은(는) agent skill입니다. fixture, parametrization, 예외 처리 및 mocking을 포함한 현대적인 Python 테스트 패턴을 구현합니다.
skill의 SKILL.md에서 생성된 요약입니다.
python-pytest-ops skill 정보
Python 애플리케이션을 위한 포괄적인 테스트 스위트를 작성할 수 있도록 지원하는 SKILL입니다. 개발자는 이 기능을 사용하여 테스트 워크플로우 내에서 fixture, parametrization, 예외 처리와 같은 현대적인 테스트 패턴을 구현할 수 있습니다. Python 3.9 이상 및 pytest 7.0 이상 버전을 사용하는 엔지니어를 위해 설계되었으며, 단위 테스트 및 통합 테스트에 필요한 구조를 제공합니다.
에이전트가 테스트 파일 생성 및 개선, conftest.py를 통한 공유 테스트 설정 관리, 또는 unittest.mock이나 pytest-mock과 같은 mocking 도구를 사용한 외부 의존성 시뮬레이션 작업을 수행할 때 이 SKILL을 로드해야 합니다. 이 SKILL은 테스트 실행을 위한 pytest, 커버리지 보고서 생성을 위한 pytest-cov, 병렬 실행을 위한 pytest-xdist와 같은 명령어를 실행하기 위해 Bash 권한이 필요합니다. 또한 개별 함수부터 전체 세션에 이르기까지 다양한 fixture scope를 통해 복잡한 테스트 시나리오를 관리할 수 있습니다.
agent가 수행할 수 있는 작업
- 1재사용 가능한 테스트 fixture 생성pytest fixture를 사용하여 데이터베이스 연결 또는 사용자 객체에 대한 setup 및 teardown 로직을 생성합니다.
- 2매개변수화된 테스트 케이스 실행단일 테스트 함수를 여러 입력 값 및 예상 출력 값 세트에 대해 실행합니다.
- 3외부 API 의존성 Mocking실제 네트워크 호출을 제어된 mock 객체로 교체하여 테스트 대상 코드를 격리합니다.
- 4에러 처리 로직 검증함수에 잘못된 입력이 제공되었을 때 특정 예외가 발생하는지 확인합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
python-pytest-ops skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.플러그인에 python-pytest-ops skill 설치
/plugin marketplace add 0xDarkMatter/claude-mods /plugin install claude-mods@claude-mods
Claude Code에 python-pytest-ops skill 설치
~/.claude/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.claude/skills/python-pytest-opsClaude Code (project)에 python-pytest-ops skill 설치
.claude/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops .claude/skills/python-pytest-opsCodex에 python-pytest-ops skill 설치
~/.agents/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.agents/skills/python-pytest-opsGemini CLI에 python-pytest-ops skill 설치
~/.gemini/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.gemini/skills/python-pytest-opsClaude.ai에 python-pytest-ops skill 설치
npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops python-pytest-ops && zip -r python-pytest-ops.zip python-pytest-ops # claude.ai → Customize → Skills → + → Create skill → Upload a skill → python-pytest-ops.zip
자동 검사
2026년 11월 15일에 실행됨전체 보고서 →아직 검증되지 않았습니다. 스킬은 점수 80, 심각한 발견 없음, 검사에 충분한 데이터가 필요합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능0xdarkmatter/claude-mods/skills/python-pytest-ops is public and reachablegithub.com/0xdarkmatter/claude-mods/tree/HEAD/skills/python- ↗통과
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit 2026-11-07github.com/0xdarkmatter/claude-mods/commits ↗통과
- 스크립트에 다운로드 후 실행이나 자격 증명 탈취가 없음2 scripts read; no download-and-run, remote eval, base64 execution or credential upload통과
- SKILL.md에 숨겨진 지침 없음No override phrases, safeguard switches, credential requests or hidden charactersgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗통과
- 사전 허용 도구가 제한됨Bash lets the agent run any shell command without askinggithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗결함 발견
- SKILL.md가 Agent Skills 형식을 따름Valid name and description; says when to use it; 207 linesgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗통과
SKILL.md
GitHub에서 보기Python pytest Patterns
Modern pytest patterns for effective testing.
Basic Test Structure
import pytest
def test_basic():
"""Simple assertion test."""
assert 1 + 1 == 2
def test_with_description():
"""Descriptive name and docstring."""
result = calculate_total([1, 2, 3])
assert result == 6, "Sum should equal 6"
Fixtures
import pytest
@pytest.fixture
def sample_user():
"""Create test user."""
return {"id": 1, "name": "Test User"}
@pytest.fixture
def db_connection():
"""Fixture with setup and teardown."""
conn = create_connection()
yield conn
conn.close()
def test_user(sample_user):
"""Fixtures injected by name."""
assert sample_user["name"] == "Test User"
Fixture Scopes
@pytest.fixture(scope="function") # Default - per test
@pytest.fixture(scope="class") # Per test class
@pytest.fixture(scope="module") # Per test file
@pytest.fixture(scope="session") # Entire test run
Parametrize
@pytest.mark.parametrize("input,expected", [
(1, 2),
(2, 4),
(3, 6),
])
def test_double(input, expected):
assert double(input) == expected
# Multiple parameters
@pytest.mark.parametrize("x", [1, 2])
@pytest.mark.parametrize("y", [10, 20])
def test_multiply(x, y): # 4 test combinations
assert x * y > 0
Exception Testing
def test_raises():
with pytest.raises(ValueError) as exc_info:
raise ValueError("Invalid input")
assert "Invalid" in str(exc_info.value)
def test_raises_match():
with pytest.raises(ValueError, match=r".*[Ii]nvalid.*"):
raise ValueError("Invalid input")
Markers
@pytest.mark.skip(reason="Not implemented yet")
def test_future_feature():
pass
@pytest.mark.skipif(sys.platform == "win32", reason="Unix only")
def test_unix_feature():
pass
@pytest.mark.xfail(reason="Known bug")
def test_buggy():
assert broken_function() == expected
@pytest.mark.slow
def test_performance():
"""Custom marker - register in pytest.ini."""
pass
Mocking
from unittest.mock import Mock, patch, MagicMock
def test_with_mock():
mock_api = Mock()
mock_api.get.return_value = {"status": "ok"}
result = mock_api.get("/endpoint")
assert result["status"] == "ok"
@patch("module.external_api")
def test_with_patch(mock_api):
mock_api.return_value = {"data": []}
result = function_using_api()
mock_api.assert_called_once()
pytest-mock (Recommended)
def test_with_mocker(mocker):
mock_api = mocker.patch("module.api_call")
mock_api.return_value = {"success": True}
result = process_data()
assert result["success"]
conftest.py
# tests/conftest.py - Shared fixtures
import pytest
@pytest.fixture(scope="session")
def app():
"""Application fixture available to all tests."""
return create_app(testing=True)
@pytest.fixture
def client(app):
"""Test client fixture."""
return app.test_client()
Quick Reference
Run these inside the project env — prefix with uv run (e.g. uv run pytest -v).
Bare pytest is shown below for brevity.
| Command | Description |
|---|---|
pytest |
Run all tests |
pytest -v |
Verbose output |
pytest -x |
Stop on first failure |
pytest -k "test_name" |
Run matching tests |
pytest -m slow |
Run marked tests |
pytest --lf |
Rerun last failed |
pytest --cov=src |
Coverage report |
pytest -n auto |
Parallel (pytest-xdist) |
Additional Resources
./references/fixtures-advanced.md- Factory fixtures, autouse, conftest patterns./references/mocking-patterns.md- Mock, patch, MagicMock, side_effect./references/async-testing.md- pytest-asyncio patterns./references/coverage-strategies.md- pytest-cov, branch coverage, reports./references/integration-testing.md- Database fixtures, API testing, testcontainers./references/property-testing.md- Hypothesis framework, strategies, shrinking./references/test-architecture.md- Test pyramid, organization, isolation strategies
Scripts
./scripts/run-tests.sh- Run tests with recommended options./scripts/generate-conftest.sh- Generate conftest.py boilerplate
Assets
./assets/pytest.ini.template- Recommended pytest configuration./assets/conftest.py.template- Common fixture patterns
See Also
Related Skills:
python-typing-ops- Type-safe test codepython-async-ops- Async test patterns (pytest-asyncio)
Testing specific frameworks:
python-fastapi-ops- TestClient, API testingpython-database-ops- Database fixtures, transactions
이 스킬의 파일
12python-pytest-ops skill 질문
Claude Code에 python-pytest-ops skill을 어떻게 설치하나요?
npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.claude/skills/python-pytest-ops를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
python-pytest-ops skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
pytest에서 사용할 수 있는 fixture scope는 무엇인가요?
fixture scope는 function(기본값), class, module 또는 session으로 정의할 수 있습니다.
'slow'로 마킹된 테스트만 실행하려면 어떻게 하나요?
pytest -m slow 명령어를 사용하여 해당 마커가 지정된 테스트를 실행할 수 있습니다.
특정 예외가 발생하는지 어떻게 테스트하나요?
pytest.raises 컨텍스트 매니저를 사용하여 예상되는 예외를 포착하고, 선택적으로 정규식과 일치하는지 확인할 수 있습니다.