pytest-code-review

Automate pytest code reviews for async patterns, fixtures, parametrization gaps, and mocking pitfalls in test_*.py files.

75|9|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/anderskev/beagle --skill pytest-code-review
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest-code-review
Source: https://github.com/anderskev/beagle/tree/main/skills/pytest-code-review
Command: npx skills add https://github.com/anderskev/beagle --skill pytest-code-review

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It provides guidelines to review Pytest test code for async patterns, fixtures, parametrization, and mocks, improving test quality.

Core Features & Use Cases

  • Async & Fixtures: Verify async tests and fixture usage.
  • Parametrize & DRY: Encourage parametrization to reduce duplication.
  • Mocks & Patches: Validate mocking patterns and patch usage.

Quick Start

Review a test file with the checklist and run pytest to surface issues.

Frequently Asked Questions about pytest-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review pytest tests for async and mock issues?

Pytest code review audits test files for async pattern weaknesses, fixture misuses, and mocking pitfalls. It identifies problems like incorrect AsyncMock usage, improper coroutine awaiting, fixture scope violations, and wrong patch targets to improve test reliability.

What async testing patterns should I check in pytest?

Verify that async test functions properly await coroutines, use AsyncMock instead of Mock for async callables, and handle fixture lifecycle correctly. This prevents race conditions and ensures async tests execute as intended.

How can parametrize reduce duplication in pytest tests?

Use @pytest.mark.parametrize to run the same test logic across multiple input sets, eliminating repetitive test functions. Code review identifies gaps where parametrization could consolidate redundant tests into a single, maintainable case.

What mocking mistakes does pytest code review catch?

The review detects incorrect patch targets, mismatched Mock vs. AsyncMock usage, missing coroutine awaits, and fixture cleanup oversights. Fixing these prevents tests from passing despite production bugs.

Can I use this review process with existing test files?

Yes, apply the checklist to any test_*.py file and run pytest to surface issues. The review works with existing test suites to identify async, fixture, parametrization, and mocking problems incrementally.

Does pytest code review work with different fixture scopes?

Yes, it validates fixture scope and cleanup strategies—function, class, module, and session scopes—ensuring fixtures initialize and tear down correctly for each test execution.