pytest

Run Python unit, integration, and async tests with pytest.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/theslashdojo/dojo --skill pytest-theslashdojo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/theslashdojo/dojo/tree/main/nodes/testing/pytest
Command: npx skills add https://github.com/theslashdojo/dojo --skill pytest-theslashdojo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, pytest-cov, pytest-asyncio, pytest-mock, pytest-xdist, and includes scripts (resource) components.

What problem does it solve?

pytest provides a robust framework for testing Python code with simple asserts, rich introspection, and a plugin ecosystem.

Core Features & Use Cases

  • Simple, expressive assertions with automatic failure diffs
  • Rich fixture system for setup/teardown and dependency injection
  • Parameterization, markers, and plugin ecosystem for scalable testing
  • Use Case: Developers can rapidly validate code changes by running a suite of tests that cover unit, integration, and asynchronous operations.

Quick Start

Install pytest and any needed plugins, write tests in files named test_*.py, and run pytest to execute the test suite.

Frequently Asked Questions about pytest

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

FAQPage Schema
How do I test asynchronous Python applications using pytest?

To test asynchronous Python applications, pytest integrates with the pytest-asyncio plugin to execute async test functions. This allows developers to validate asynchronous operations using standard pytest fixtures and assertions.

Can I run pytest tests in parallel to speed up execution?

Yes, you can run pytest tests in parallel using the pytest-xdist plugin. This distributes test execution across multiple CPUs, delivering faster and more repeatable test results for large unit and integration suites.

How do I measure code coverage when running Python tests?

You measure code coverage during Python testing by integrating the pytest-cov plugin. It reports which code lines your tests execute, ensuring reliable validation of unit and integration test scenarios.

What is the best way to manage setup and teardown in Python testing?

The best way to manage setup and teardown in Python testing is using pytest fixtures. Fixtures provide dependency injection and handle initialization and cleanup, ensuring repeatable test results across unit and integration tests.

How do I parameterize Python tests to run multiple input scenarios?

You parameterize Python tests using pytest's built-in parametrize feature to run a single test function against multiple input sets. This scales test coverage efficiently without duplicating test code.

Do I need pyproject.toml to configure pytest conventions?

You can configure pytest conventions and discovery rules through pyproject.toml. Enforcing configuration options in this file ensures consistent test execution and plugin behavior across your testing environment.