pytest-testing

Automate pytest-based testing workflows for Python projects.

9|1|Updated Jun 16, 2026
One-click install
npx skills add https://github.com/AratKruglik/antigravity-sdlc --skill pytest-testing-aratkruglik
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest-testing
Source: https://github.com/AratKruglik/antigravity-sdlc/tree/main/plugins/python-foundation/skills/pytest-testing
Command: npx skills add https://github.com/AratKruglik/antigravity-sdlc --skill pytest-testing-aratkruglik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

pytest testing patterns for any Python project: test structure, fixtures, parametrize, unittest.mock (MagicMock, patch), pytest-cov coverage, and best practices. Stack-agnostic — referenced by every Python plugin in the marketplace.

Use this skill to:

  • Organise tests with conftest.py shared fixtures and a clear test/src layout.
  • Write parametrized tests to cover multiple inputs without duplication.
  • Mock external dependencies (HTTP, DB, filesystem) with unittest.mock and monkeypatch.
  • Measure and enforce code coverage with pytest-cov.

Do NOT use this skill for:

  • Framework-specific test types (Django TestCase / WebTestCase, FastAPI TestClient, Flask test client — see framework plugin skills).
  • Language idioms — see python-foundation:python-conventions.

Core Features & Use Cases

  • conftest.py — shared fixtures and fixture scopes.
  • Fixture scopes: function / module / class / session.
  • Parametrize — data-driven tests with pytest.mark.parametrize.
  • Monkeypatch — patching attributes and environment during tests.
  • unittest.mock — mocking objects and calls for interaction tests.
  • tmp_path — temporary filesystem fixtures for file I/O.
  • Coverage — integrate pytest-cov to measure and report test coverage.

Quick Start

Run pytest from your project root to execute tests and verify coverage.

Frequently Asked Questions about pytest-testing

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

FAQPage Schema
How do I organize pytest tests and share fixtures across a Python project?

Organize pytest tests by placing shared fixtures in a conftest.py file at the root or test directory. This allows you to define fixture scopes for function, module, class, or session levels, making reusable test setup available across your Python project without duplication.

How do I parametrize tests in pytest to cover multiple inputs?

Parametrize tests using the pytest.mark.parametrize decorator to feed multiple data sets into a single test function. This data-driven testing approach eliminates duplication by automatically generating distinct test cases for each input combination you specify.

What is the best way to mock external dependencies like HTTP or database calls in pytest?

Mock external dependencies in pytest by using unittest.mock tools like MagicMock and patch, or apply monkeypatch to modify attributes and environment variables. These approaches isolate tests from HTTP, database, and filesystem interactions for reliable execution.

How do I measure code coverage in a Python project with pytest?

Measure code coverage in pytest by integrating the pytest-cov plugin. Run pytest from your project root to execute tests and generate coverage reports, enforcing code coverage thresholds to ensure your Python project maintains adequate test coverage.

Does this pytest testing skill support framework-specific tests like Django TestCase or FastAPI TestClient?

This pytest testing skill does not support framework-specific test types like Django TestCase, FastAPI TestClient, or Flask test client. It focuses on stack-agnostic pytest patterns including fixtures, parametrization, mocks, and coverage measurement.

How do I test file I/O operations safely in pytest without modifying the real filesystem?

Test file I/O operations safely in pytest using the tmp_path utility fixture. It creates a unique temporary directory for each test invocation, allowing you to read and write files during testing without modifying the real filesystem.