write-tests

Write pytest tests for AutoReview modules with mocked LLM responses.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/mcleanT/AutoReview --skill write-tests-mcleant
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-tests
Source: https://github.com/mcleanT/AutoReview/tree/main/.claude/skills/write-tests
Command: npx skills add https://github.com/mcleanT/AutoReview --skill write-tests-mcleant

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill codifies AutoReview's testing conventions so contributors can write reliable, consistent pytest tests that correctly mock LLM behavior, handle asynchronous code, and reuse shared fixtures without guessing project patterns.

Core Features & Use Cases

  • Conventions enforcement: Specifies asyncio_mode = auto, test file and class naming, and use of module-level make* builders for test data.
  • Mock LLM patterns: Documents static, sequence, and dispatch mock LLM classes and requires wrapping outputs in LLMResponse or LLMStructuredResponse for deterministic assertions.
  • Fixtures and integration guidance: Lists available conftest fixtures, how to patch external APIs, and when to mark tests as integration.
  • Use case: Create unit and integration tests for extraction and synthesis components that assert prompt content, response model identity, and structured parsing behavior.

Quick Start

Write a pytest test file for a target module that defines a local MockLLM returning structured LLM responses and uses the provided conftest fixtures and make* builders.

Frequently Asked Questions about write-tests

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

FAQPage Schema
How do I write pytest tests for async functions that mock LLM responses?

To write pytest tests mocking LLM responses, set asyncio_mode to auto and define local Mock*LLM classes returning LLMResponse or LLMStructuredResponse for deterministic assertions. This ensures reliable testing of asynchronous functions and structured outputs.

What's the best way to structure test data builders for pytest unit tests?

The best way to structure test data builders is using module-level _make_* builders. This enforces consistent test data creation conventions and allows tests to reuse provided conftest fixtures for sample data across unit and integration tests.

Can I use pytest fixtures to patch external APIs in integration tests?

Yes, you can patch external APIs in integration tests using provided conftest fixtures. Mark tests as integration when covering external API mocking, and use local Mock*LLM classes to wrap responses in LLMStructuredResponse for deterministic parsing assertions.

How does mocking LLM outputs work with structured response models?

Mocking LLM outputs works by wrapping responses in LLMStructuredResponse objects returned from local Mock*LLM classes. This enables tests to assert structured parsing behavior, prompt content, and response model identity without live API calls.

Do I need pytest asyncio_mode auto for testing asynchronous LLM functions?

Yes, asyncio_mode must be set to auto when testing asynchronous LLM functions. This configuration enables pytest to automatically handle async test functions, allowing reliable execution of tests covering asynchronous extraction and synthesis components.

When should I mark pytest tests as integration tests for API mocking?

Mark pytest tests as integration tests when they involve patching external APIs. Unit tests should use local Mock*LLM classes with LLMResponse wrappers, while integration tests cover broader interactions with external API mocking and shared conftest fixtures.