pytest

Create and execute Python unit and integration tests with pytest.

Updated Feb 18, 2026
One-click install
npx skills add https://github.com/vanhoangkha/cloud-security-audit --skill pytest-vanhoangkha
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/vanhoangkha/cloud-security-audit/tree/main/multi-cloud/prowler/skills/pytest
Command: npx skills add https://github.com/vanhoangkha/cloud-security-audit --skill pytest-vanhoangkha

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of writing robust and efficient tests for Python applications, ensuring code quality and reliability.

Core Features & Use Cases

  • Test Structure: Provides examples for basic test cases, fixtures, and conftest.py usage.
  • Mocking: Demonstrates effective techniques for mocking external dependencies using unittest.mock.
  • Parametrization & Markers: Shows how to run tests with different data inputs and categorize them using markers.
  • Use Case: When developing a new feature, use this Skill to quickly scaffold unit tests, including setting up necessary fixtures and mocking API calls, to verify the feature's correctness.

Quick Start

Use the pytest skill to write a basic test function that asserts the equality of two values.

Frequently Asked Questions about pytest

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

FAQPage Schema
How do I write a Python unit test using pytest fixtures and conftest.py?

Python unit testing with pytest fixtures involves defining reusable setup functions in conftest.py to provide baseline data or states to your test cases. This approach streamlines test structure and ensures consistent test execution across your application.

What is the best way to mock API calls in Python tests?

Mocking API calls in Python tests is best handled using unittest.mock to replace external dependencies with controlled responses. This technique isolates the code being tested, ensuring reliable and fast test execution without hitting actual endpoints.

How does parametrization work in pytest test suites?

Parametrization in pytest allows running a single test function against multiple sets of data inputs. It works by applying decorators to pass different arguments, ensuring efficient test suite management and broad coverage without duplicating test code.

Can I run asynchronous test functions with pytest?

Yes, pytest supports asynchronous test functions to verify concurrent code and async API integrations. It handles the execution of async test cases natively, allowing you to validate non-blocking operations within your integration tests.

How do I categorize and filter tests using pytest markers?

Categorizing tests with pytest markers involves assigning custom tags to test functions to group them logically. You can then filter and execute specific marker subsets during test runs, improving efficiency by targeting only relevant tests.

Does pytest integrate with coverage tools for Python testing?

Yes, pytest integrates with coverage tools to measure code execution during test runs. This integration generates detailed reports on untested code paths, ensuring comprehensive validation and improving overall application reliability.