← Back to Skills Marketplace
46
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install python-testing
Description
Python 测试速查。当需要:(1) 运行 pytest 测试 (2) 使用 mock/patch (3) 参数化测试 (4) fixtures (5) 异步测试 (6) 覆盖率测试时使用。
README (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 详解: references/pytest.md - 完整 pytest 用法
- Mock 和 Patch: references/mocking.md - unittest.mock 详解
- Fixtures: references/fixtures.md - fixture 高级用法
- 异步测试: references/async.md - pytest-asyncio
- 覆盖率: references/coverage.md - pytest-cov 配置
常用标记
@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
文档
- pytest: https://docs.pytest.org/
- pytest-cov: https://pytest-cov.readthedocs.io/
Usage Guidance
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.
Capability Analysis
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.
Capability Tags
Capability Assessment
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.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install python-testing - After installation, invoke the skill by name or use
/python-testing - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release
Metadata
Frequently Asked Questions
What is Python Testing?
Python 测试速查。当需要:(1) 运行 pytest 测试 (2) 使用 mock/patch (3) 参数化测试 (4) fixtures (5) 异步测试 (6) 覆盖率测试时使用。 It is an AI Agent Skill for Claude Code / OpenClaw, with 46 downloads so far.
How do I install Python Testing?
Run "/install python-testing" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Python Testing free?
Yes, Python Testing is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Python Testing support?
Python Testing is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Python Testing?
It is built and maintained by afine907 (@afine907); the current version is v1.0.0.
More Skills