跳到正文
cccskills
免费在 GitHub 公开

pytest-gen

Generate comprehensive pytest tests - use when generating tests, creating test suites, or testing Python code

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md1.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Pytest Generation Skill

When generating tests, follow this structure.

Test Organization

  • Group tests by function under test
  • Use @pytest.mark.parametrize for multiple inputs
  • Use fixtures for shared setup
  • Follow arrange/act/assert pattern

Coverage Requirements

  • Happy path (expected usage)
  • Edge cases (empty strings, None, boundary values)
  • Error cases (invalid input, file not found, wrong types)
  • Integration (functions working together)

Template

import pytest
from module_under_test import function_to_test


@pytest.fixture
def sample_data():
    """Provide shared test data."""
    return {"key": "value"}


class TestFunctionName:
    """Tests for function_name."""

    def test_happy_path(self, sample_data):
        result = function_to_test(valid_input)
        assert result == expected_output

    def test_empty_input(self):
        result = function_to_test("")
        assert result == expected_for_empty

    @pytest.mark.parametrize("input_val,expected", [
        ("valid", True),
        ("", False),
        (None, False),
    ])
    def test_various_inputs(self, input_val, expected):
        assert function_to_test(input_val) == expected

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Team code quality checklist - use for checking Python code quality, bugs, security issues, and best practices

中文简介正在准备中。当前显示原文说明。

github/copilot-cli-for-beginners28912026年10月15日 更新

Generate conventional commit messages - use when creating commits, writing commit messages, or asking for git commit help

中文简介正在准备中。当前显示原文说明。

github/copilot-cli-for-beginners28912026年10月15日 更新

A minimal skill example - use when learning the skill format

中文简介正在准备中。当前显示原文说明。

github/copilot-cli-for-beginners28912026年10月15日 更新

查看 github 的全部技能

报告此技能的问题