본문으로 건너뛰기
cccskills
무료GitHub에 공개

python-testing

Write focused, deterministic, well-documented pytest tests for AI-authored code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(3)

  • SKILL.md4.3 KB
  • assets/pytest.ini.template91 B
  • scripts/analyze_coverage.sh207 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

What I do

I help with three pytest workflows:

  1. Write tests — generate focused, well-documented tests following project conventions
  2. Check coverage — detect untested lines per file or folder
  3. Bootstrap setup — install dev dependencies and apply recommended pytest configuration

Supporting files in this skill:

  • assets/pytest.ini.template — ready-to-copy pytest configuration
  • scripts/analyze_coverage.sh [path] — coverage analysis helper (whole src or specific folder/module)
    • Run from repo root as: ./.claude/skills/python-testing/scripts/analyze_coverage.sh [path]
    • Or use repo-root-safe path: "$(git rev-parse --show-toplevel)/.claude/skills/python-testing/scripts/analyze_coverage.sh" [path]

When to use me

Use when you want to:

  • Write new tests for a module or feature
  • Review and improve existing test quality
  • Check coverage for a specific file, folder, or the whole project
  • Bootstrap pytest for a new project (deps + config)

Example usage

"Write tests for the slugify function in src/utils/text.py" "Check coverage for src/services/payment.py" "Set up pytest for this project with coverage and async support"


Conventions

Naming

  • Files: test_<module_or_feature>.py
  • Functions: test_<unit>__<behavior>__<condition>
  • Mark every AI-generated test with @pytest.mark.ai

Docstring (required on every test)

Three-part format:

Purpose: What this test verifies.
Why this matters: Business or technical consequence if it breaks.
Setup summary: What's arranged and what's asserted.

Structure

  • AAA pattern: Arrange – Act – Assert
  • No conditionals or loops in test body (use parametrization)
  • One responsibility per test

Fixtures

  • Centralize in <domain>_fixtures.py
  • Register via pytest_plugins = ["tests.fixtures"] in conftest.py
  • Return typed objects; modify only what changes per test

Mocking

  • Use mocker fixture (pytest-mock)
  • Mock at the import boundary of the code under test
  • Use spec=True for type safety

Coverage

  • Target ≥ 80% for AI-authored tests
  • ./.claude/skills/python-testing/scripts/analyze_coverage.sh — full src coverage
  • ./.claude/skills/python-testing/scripts/analyze_coverage.sh src/services — coverage for a specific folder
  • ./.claude/skills/python-testing/scripts/analyze_coverage.sh src/utils/text.py — coverage for a single file

Test scope & quality

  • Test every public function and method you touched
  • Cover happy paths plus negative scenarios, validation failures, and async edge cases
  • Keep tests deterministic and isolated (clean up temp data, reset mocks)
  • Mock only external dependencies using pytest-mock's mocker or hand-rolled fixtures
  • Document why each test matters using the required docstring template

Test cases to include

  • Happy path scenarios that reflect realistic inputs
  • Edge cases such as empty inputs, boundary values, and timeout paths
  • Error handling or exception flows (raise and capture specific exceptions)
  • Dependency failures (e.g., network timeouts, missing files) while staying fast
  • Concurrency and async behavior when applicable (use pytest.mark.asyncio or trio)

Test quality checklist

  • Tested all public functions and methods touched by the change
  • Covered happy path scenarios plus edge cases and negative flows
  • Added or updated tests for error handling and exception cases
  • Mocked external dependencies appropriately and kept mocks scoped
  • Ensured all tests are deterministic and repeatable
  • Kept tests focused (one assertion per behavior) and avoided loops/conditionals
  • Documented each test with the three-part docstring
  • Verified coverage with scripts/analyze_coverage.sh when changes affect multiple modules

Setup (new project)

  1. Install dev dependencies:
    • uv: uv add --dev pytest pytest-cov pytest-asyncio pytest-mock
    • pip: pip install pytest pytest-cov pytest-asyncio pytest-mock
  2. Copy assets/pytest.ini.template → pytest.ini at the project root
  3. Add tests/ directory with an empty __init__.py and conftest.py

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Implement comprehensive error handling for Python code paths to keep services resilient and user-friendly. Use when failures are currently silent or exceptions leak through.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Tabular and numerical data analysis with descriptive statistics and insights. Use when the user provides data, tables, CSVs, or numbers and wants analysis.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Financial factsheet analysis with key metrics extraction and investment rationale

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

ci-fix

무료

Diagnose and fix CI failures without leaving your editor.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Reproduce ai-repo PR checks locally with Poe and CI scripts, including per-package typecheck and coverage behavior. Use when validating changes before push or when user asks which local commands match CI.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Ask clarifying questions before implementing to ensure Python requirements are understood. Use when a task lacks detail, dependencies are unclear, or multiple interpretations are possible.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Unique-AG의 스킬 모두 보기

이 스킬의 문제 신고