Python Pytest Pro — Fixtures & Parametrize

    1

    Pytest-depth tests: fixtures, parametrize, monkeypatch — confirm before production edits.

    $24

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Python Pytest Pro — Fixtures & Parametrize

    Example session with this skill installed

    python-pytest-pro: write tests for my user authentication logic in auth.py. I need to test successful login and failed attempts with different status codes.

    • Read your context and instructions
    • Compiled the python pytest pro

    I have analyzed your auth.py and detected a standard tests/ directory structure. I will now create a test suite using pytest.mark.parametrize for the failure cases and a fixture for the API client session.

    Test Suite Implementation

    import pytest
    from my_app.auth import AuthService
    
    @pytest.fixture
    def auth_service(monkeypatch):
        """Provides a service instance with mocked network calls."""
        service = AuthService()
        # Mocking actual network request to avoid side effects
        monkeypatch.setattr(service, "_call_provider", lambda x: {"status": 200})
        return service
    
    @pytest.mark.parametrize("credentials, expected_status", [
        ({"user": "admin", "pass": "wrong"}, 401),
        ({"user": "nonexistent", "pass": "pass"}, 404),
        ({"user": "", "pass": ""}, 400),
    ])
    def test_login_failures(auth_service, credentials, expected_status):
        """Verifies authentication failures return correct status codes."""
        response = auth_service.login(credentials["user"], credentials["pass"])
        assert response.status_code == expected_status
    
    def test_login_success(auth_service, monkeypatch):
        """Verifies successful authentication flow."""
        monkeypatch.setattr(auth_service, "_call_provider", lambda x: {"status": 200, "token": "abc"})
        response = auth_service.login("valid_user", "correct_pass")
        assert response.status_code == 200
        assert "token" in response.data
    

    Next steps

    1. Run pytest tests/test_auth.py -q to verify the new suite.
    2. Review the monkeypatch logic to ensure it aligns with your auth provider's response schema.
    3. Approve production edits to auth.py if logic adjustments are needed for the 404 case.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Writing tests that actually catch bugs requires more than just calling functions. Generic AI prompts often miss essential pytest idioms, resulting in brittle suites or skipped edge cases. This skill enforces professional testing standards by leveraging advanced pytest features like fixtures, parametrization, and monkeypatching.

    What it does

    • Advanced fixtures handles setup and teardown logic using idiomatic shared fixtures to keep tests DRY.
    • Data parametrization generates test matrices to cover multiple input scenarios without duplicating code.
    • Dependency isolation uses monkeypatch to mock external calls and network traffic, ensuring deterministic results.
    • Structural detection identifies existing pytest.ini, pyproject.toml, or tests/ layouts to maintain project consistency.
    • TDD workflow follows a strict red-green-refactor cycle, identifying failures before applying production fixes.

    How it works

    1. Detect environment by scanning for configuration files and async plugins.
    2. Define failures by naming the failing test and assertion, then listing required production edits for approval.
    3. Implement tests by placing code in conventional paths and running targeted pytest commands.
    4. Refactor suite by consolidating shared fixtures and expanding parametrization.

    Frameworks & tools

    This skill is designed for Python projects utilizing pytest. It supports projects with pytest-asyncio and standard configuration files like pyproject.toml or pytest.ini.

    Why this beats prompting it yourself

    Standard prompts often produce flat, repetitive test scripts that ignore established project structures. This skill enforces the use of specific pytest idioms and requires explicit confirmation before touching production code, preventing accidental regressions.

    Use cases

    • Add comprehensive test coverage to a legacy Python module.
    • Fix broken test suites by identifying the specific assertion failure.
    • Mock external API calls using monkeypatch to enable offline testing.
    • Refactor repetitive tests into clean, parametrized matrices.

    Known limitations

    Requires an existing Python environment with pytest installed. Does not generate arbitrary coverage percentage reports.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.

    Requires pytest to be installed in the environment. Will not delete or skip tests without explicit user confirmation. Does not support automated coverage percentage generation.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 24 days ago

    Software
    Python

    Permissions

    Read Files
    Listed27 days ago

    What's inside

    Frequently Asked Questions

    This skill automates the creation of professional-grade test suites, using idiomatic features like fixtures and parametrization to replace brittle, repetitive test scripts with clean and maintainable code.

    Yes, the skill is designed to detect your existing project layout (such as pyproject.toml or pytest.ini) and will place new tests in your established directories to maintain consistency.

    The skill is compatible with standard Python environments and specifically supports projects using pytest and pytest-asyncio for asynchronous testing.

    This skill uses the monkeypatch fixture to mock external dependencies, ensuring your test suite remains deterministic and can run without active network connections or API access.

    You will receive the full skill logic optimized for pytest, ready to be integrated into your preferred AI agent or development workflow, along with documentation on how to trigger its TDD cycles.

    New in Testing & Debugging