Pytest Code Review for Openclaw

A specialized AI skill designed to review and optimize pytest code for asynchronous patterns, fixture efficiency, and mocking accuracy.

anderskev
v1.1.1
Apr 22, 2026
0
912
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install pytest-code-review

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install pytest-code-review using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Pytest Code Review?

The Pytest Code Review skill is a sophisticated tool within the Openclaw Skills ecosystem tailored for Python developers. It automates the tedious process of reviewing test suites by enforcing a rigorous set of gates. It evaluates everything from basic test structure to complex asynchronous behaviors and mock injection points, ensuring that your test code is as high-quality as your production code.

By leveraging this skill, teams can maintain a high standard of test hygiene. It helps in identifying resource leaks in fixtures and ensuring that mocks are tracking calls correctly, which significantly reduces flaky tests and false positives in CI/CD pipelines.

Pytest Code Review Use Cases

  • Auditing asynchronous test functions to ensure they are properly awaited and use AsyncMock.
  • Reviewing conftest.py files to manage shared setup and teardown logic effectively.
  • Refactoring repetitive test cases into clean, DRY patterns using pytest parametrization.
  • Troubleshooting complex mocking scenarios where patches might be targeting the wrong location.

How Pytest Code Review Works

  1. Scoped File Analysis: The agent identifies and lists all test_*.py and conftest.py files targeted for review.
  2. Async vs Sync Check: It differentiates between synchronous and asynchronous test functions, applying specific rules for await patterns.
  3. Fixture Evaluation: The skill inspects fixtures for proper scope (function, class, module, or session) and mandatory cleanup in yield fixtures.
  4. Mock and Patch Validation: It verifies that patch targets are defined at the call site and that AsyncMock is used for async dependencies.
  5. Structured Findings: The process concludes by generating specific, actionable findings mapped to exact line numbers and file paths.

Pytest Code Review Setup

To begin using this skill within your Openclaw Skills workflow, ensure your environment is configured for Python development.

# Install the skill via your preferred agent interface
openclaw install pytest-code-review

# Run a review on your current test directory
openclaw run pytest-code-review --path ./tests

Pytest Code Review Data Schema & Taxonomy

Data Element Specification
Supported Files Matches test_*.py and conftest.py patterns
Issue Taxonomy Categorized into Async, Fixtures, Parametrize, and Mocking
Metadata Includes test node IDs, line numbers, and file paths for precise debugging
References Connects to internal documentation like async-testing.md and fixtures.md

Pytest Code Review Advanced Features

  • Contextual reference loading that pulls in specific documentation based on the code being reviewed.
  • Automated validation of fixture cleanup logic to prevent memory leaks and resource exhaustion.
  • Cross-file analysis between test files and conftest.py for holistic fixture scoping.
  • Support for advanced mock tracking using assert_called_once_with and similar patterns.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*