← 返回 Skills 市场
afine907

Python Testing

作者 afine907 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
46
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install python-testing
功能描述
Python 测试速查。当需要:(1) 运行 pytest 测试 (2) 使用 mock/patch (3) 参数化测试 (4) fixtures (5) 异步测试 (6) 覆盖率测试时使用。
使用说明 (SKILL.md)

Python Testing

Python 测试框架核心用法速查。

快速参考

pytest 基础

pytest                        # 运行所有测试
pytest -v                     # 详细输出
pytest test_module.py         # 指定文件
pytest -k "login"             # 匹配测试名
pytest -x                     # 失败时停止
pytest -n 4                   # 并行执行

测试示例

def test_addition():
    assert 1 + 1 == 2

@pytest.mark.parametrize("a,b,expected", [(1,2,3), (2,3,5)])
def test_add(a, b, expected):
    assert add(a, b) == expected

Mock

from unittest.mock import Mock, patch

mock_db = Mock()
mock_db.query.return_value = []

@patch('module.function')
def test_with_mock(mock_func):
    mock_func.return_value = 42

Fixture

@pytest.fixture
def database():
    db = Database(":memory:")
    yield db
    db.close()

def test_query(database):
    assert database.query("SELECT 1")

覆盖率

pytest --cov=myapp
pytest --cov=myapp --cov-report=html

详细参考

常用标记

@pytest.mark.slow              # 标记慢测试
@pytest.mark.integration       # 标记集成测试
@pytest.mark.skip(reason="TODO")
@pytest.mark.skipif(sys.version_info \x3C (3, 10))

pytest.ini 配置

[pytest]
testpaths = tests
python_files = test_*.py
markers =
    slow: marks tests as slow
    integration: integration tests
addopts = -v --tb=short

文档

安全使用建议
This skill appears safe as a documentation-only Python testing reference. Before using it to run commands, make sure the repository is trusted, prefer a virtual environment, and approve any package installation or pytest execution.
功能分析
Type: OpenClaw Skill Name: python-testing Version: 1.0.0 The skill bundle is a comprehensive reference guide for Python testing using pytest and related libraries. It contains only documentation and standard code examples for testing, mocking, and coverage across files like SKILL.md and various reference markdown files. No malicious patterns, data exfiltration, or prompt injection attempts were found.
能力标签
requires-sensitive-credentials
能力评估
Purpose & Capability
The artifacts consistently provide Python testing reference material for pytest, mocks, fixtures, async tests, and coverage, matching the stated description.
Instruction Scope
SKILL.md includes scoped command examples such as `pytest # 运行所有测试`; running tests is expected for this skill, but it executes code from the current project.
Install Mechanism
There is no install spec or bundled code, but reference files include optional setup commands such as `pip install pytest-asyncio`; these are normal testing-tool setup snippets, not automatic installs.
Credentials
The requirements declare no env vars, primary credential, binaries, or config paths. The sensitive-credential capability signal is not supported by the actual artifacts beyond placeholder mock examples.
Persistence & Privilege
No persistence, background process, privilege escalation, account access, or hidden helper behavior is shown. Coverage examples may create local reports only if the user runs them.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install python-testing
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /python-testing 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
Slug python-testing
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Python Testing 是什么?

Python 测试速查。当需要:(1) 运行 pytest 测试 (2) 使用 mock/patch (3) 参数化测试 (4) fixtures (5) 异步测试 (6) 覆盖率测试时使用。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 46 次。

如何安装 Python Testing?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install python-testing」即可一键安装,无需额外配置。

Python Testing 是免费的吗?

是的,Python Testing 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Python Testing 支持哪些平台?

Python Testing 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Python Testing?

由 afine907(@afine907)开发并维护,当前版本 v1.0.0。

💬 留言讨论