一键导入
qa-pytest-writer
Generate pytest unit and integration tests for Python with fixtures, parametrize, markers, conftest patterns, and plugin ecosystem support.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate pytest unit and integration tests for Python with fixtures, parametrize, markers, conftest patterns, and plugin ecosystem support.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Master skill coordinating all QA skills through pipeline modes (full-cycle, docs-only, testcases-only, write-tests, report), formalized handoff chains, scheduler rules, and framework/language selection based on project context.
QA project memory with auto-update. Structured log of bugs, decisions, tests, regressions, environments. Automatically updated after every QA task. Archive system with searchable index for large projects. Trigger phrases (EN): "initialize memory", "init qa memory", "find known bug", "search memory", "show what was done", "check regressions", "memory status", "archive memory", "log a bug", "add decision", "memory summary", "what bugs do we know", "update memory", "show test log". Trigger phrases (UA): "ініціалізувати пам'ять", "знайти відомий баг", "пошук у пам'яті", "показати що було зроблено", "перевірити регресії", "статус пам'яті", "архівувати пам'ять", "залогувати баг", "додати рішення", "зведення пам'яті", "які баги відомі", "оновити пам'ять", "показати лог тестів", "що ми вирішили про", "які тестові середовища є".
Analyze OpenAPI/Swagger spec (JSON or YAML) against existing test files and generate an HTML coverage report with QA automation tasks. Use when user provides an OpenAPI spec file and wants to know test coverage status.
Generate accessibility tests for WCAG 2.2 compliance using axe-core, Pa11y, and Lighthouse with automated checks for ARIA patterns, keyboard navigation, color contrast, and screen reader support.
Manage and formalize API contracts from existing endpoints, swagger/JSON, network traffic, or developer interviews into OpenAPI specifications.
Autonomously explore live web applications using Playwright MCP to collect page structure, form fields, validation rules, API endpoints, and user flows for test case generation.
| name | qa-pytest-writer |
| description | Generate pytest unit and integration tests for Python with fixtures, parametrize, markers, conftest patterns, and plugin ecosystem support. |
| output_dir | tests/unit |
Write pytest unit and integration tests from test case specifications. Transform structured test cases (from qa-testcase-from-docs, qa-manual-test-designer, or specs) into executable pytest code with fixtures, parametrization, markers, and conftest patterns.
| Feature | Description |
|---|---|
| Fixtures | Scope: function, class, module, session; autouse, yield for teardown |
| @pytest.mark.parametrize | Data-driven tests with multiple input/output sets |
| Markers | skip, skipif, xfail, custom markers for categorization |
| conftest.py | Shared fixtures across test modules/directories |
| Plugin ecosystem | pytest-cov, pytest-xdist, pytest-asyncio, pytest-html, pytest-factoryboy |
| Assertion introspection | Rich failure output; plain assert statements |
test_{module}.py with test functionspytest to execute testsUse Context7 MCP for current pytest documentation when:
| Pattern | Usage |
|---|---|
test_ prefix | Test functions: def test_something(): |
assert | Plain assertions; no special API needed |
| Fixtures | def fixture_name(): with scope, autouse, yield |
@pytest.mark.parametrize | Data-driven tests |
| Markers | @pytest.mark.skip, @pytest.mark.skipif, @pytest.mark.xfail |
| conftest.py | Shared fixtures in package/directory |
| monkeypatch | Built-in for patching attributes/env |
| tmp_path | Built-in temporary directory fixture |
| unittest.mock | patch, MagicMock for mocking |
| Approach | Use Case |
|---|---|
| unittest.mock.patch | Patch modules, classes, functions |
| unittest.mock.MagicMock | Create mock objects with configurable behavior |
| pytest-mock (mocker) | mocker fixture wraps patch; cleaner syntax |
| monkeypatch | Built-in; patch attributes, env vars, sys.path |
[tool.pytest.ini_options]See references/config.md for configuration patterns.
| Plugin | Purpose |
|---|---|
| pytest-cov | Code coverage reporting |
| pytest-xdist | Parallel test execution |
| pytest-asyncio | Async test support |
| pytest-html | HTML test reports |
| pytest-factoryboy | Factory fixtures for models |
test_{module}.py — Preferred (e.g., test_calculator.py)tests/ or colocated with source per project conventionCan do (autonomous):
Cannot do (requires confirmation):
Will not do (out of scope):
pytest)references/patterns.md — Fixtures, parametrize, conftest, async testing, mockingreferences/assertions.md — Assertion patterns: comparison, exceptions, warnings, approximatereferences/config.md — pyproject.toml, pytest.ini, conftest.py, markers, pluginsreferences/best-practices.md — Fixture scope, naming, organization, test isolation, coveragetest_{module}.py convention| Symptom | Likely Cause | Fix |
|---|---|---|
| Fixture not found | Scope or conftest location | Ensure conftest.py in same dir or parent; check fixture scope |
| Parametrize id collision | Duplicate ids | Use ids parameter for unique test names |
| Tests pass individually, fail together | Shared mutable state | Use function-scoped fixtures; avoid module/session for mutable data |
| monkeypatch not persisting | Wrong target path | Patch where object is used (e.g., mymodule.func not builtins.func) |
| Async tests fail | Missing pytest-asyncio | Add @pytest.mark.asyncio; install pytest-asyncio |
| Coverage not collected | Plugin not configured | Add pytest-cov; run pytest --cov=src |
| Import errors in tests | Path/sys.path | Add conftest.py with sys.path or use pyproject.toml pythonpath |