pytest

Automate Python unit, integration, and API tests with pytest.

Updated Feb 25, 2023
One-click install
npx skills add https://github.com/GeorgeKuzora/dotfiles --skill pytest-georgekuzora
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/GeorgeKuzora/dotfiles/tree/main/dot_config/opencode/skills/pytest
Command: npx skills add https://github.com/GeorgeKuzora/dotfiles --skill pytest-georgekuzora

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

pytest provides a powerful, flexible testing framework for Python that makes writing, organizing, and running tests easier through fixtures, parametrization, and a rich plugin ecosystem. It supports integration with FastAPI, Django, Flask, and asynchronous code, enabling teams to go from failing tests to reliable software faster.

Core Features & Use Cases

  • Fixture system for dependency injection and reusable setup
  • Parametrization and markers for data-driven and categorized tests
  • Wide plugin ecosystem (cov, asyncio, mock, Django, etc.) for extended capabilities
  • Async support, test discovery, and rich assertion introspection
  • Seamless integration with FastAPI, Django, and Flask projects
  • Use cases include unit tests, integration tests, API testing, and test-driven development workflows

Quick Start

Install pytest and common plugins, create test_*.py files, use fixtures via @pytest.fixture and parameterization via @pytest.mark.parametrize, then run pytest -v to execute.

Frequently Asked Questions about pytest

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

FAQPage Schema
How do I write and run Python tests using pytest?

pytest supports comprehensive Python testing workflows across FastAPI, Django, Flask, and plain Python projects, handling unit, integration, and API tests with fixtures, parametrization, markers, and plugin integration.

Can I use pytest for async testing in Python?

Yes, pytest supports asynchronous Python testing by leveraging its plugin ecosystem, such as asyncio integration, enabling teams to write and execute reliable async test cases for non-blocking applications.

Does pytest work with FastAPI, Django, and Flask projects?

pytest integrates seamlessly with FastAPI, Django, and Flask projects, enabling comprehensive unit, integration, and API testing workflows while utilizing fixtures for dependency injection and reusable test setup.

What is the best way to manage test setup and dependency injection in Python?

The best way to manage test setup and dependency injection in Python is using the pytest fixture system, which provides reusable setup mechanisms and supports a wide plugin ecosystem for extended testing capabilities.

How do I generate test coverage reports with pytest?

To generate test coverage reports with pytest, use the cov plugin from its wide plugin ecosystem, which satisfies test discovery and coverage reporting requirements while running your unit and integration test suites.