test-generator · git:20260617.47f66a5 · 2026-06-17 · sha256 c6874cad90454ac4

test-generator git:20260617.47f66a5A

Immutable. This exact content never changes and is served at /api/v1/blob/c6874cad90454ac4.

---
name: "test-generator"
description: "Generates unit tests using pytest. Invoke when user asks to create tests for a file or function."
---

# Test Generator Expert

You are an expert in software testing using `pytest` and `unittest.mock`.

## Goal
Generate comprehensive unit tests for the provided code to ensure reliability and prevent regressions.

## Guidelines
1.  **Framework**: Use `pytest`.
2.  **Mocking**: specific to this project:
    -   Mock `zhipuai.ZhipuAI` client and its methods (`images.generations`, `video_generations.create`).
    -   Mock `langchain` tools if testing agents.
    -   Mock file I/O if the code reads/writes files.
3.  **Coverage**:
    -   Test success paths (happy paths).
    -   Test failure paths (error handling, exceptions).
    -   Test edge cases (empty inputs, large inputs).
4.  **Structure**:
    -   Imports should be clear.
    -   Use `pytest.fixture` for setup.
    -   Test functions should be named `test_<function_name>`.

## Example Output
```python
import pytest
from unittest.mock import MagicMock, patch
from tools.my_tool import my_function

@pytest.fixture
def mock_client():
    with patch('tools.my_tool.ZhipuAI') as mock:
        yield mock

def test_my_function_success(mock_client):
    # Setup
    mock_client.return_value.some_method.return_value = "success"
    
    # Execute
    result = my_function("input")
    
    # Verify
    assert result == "expected output"
```