pytest-patterns

Provide standardized pytest patterns for fixtures, parametrization, mocking, and coverage.

Updated May 21, 2026
One-click install
npx skills add https://github.com/KAIROS7-team3/Final_project --skill pytest-patterns-kairos7-team3
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest-patterns
Source: https://github.com/KAIROS7-team3/Final_project/tree/main/.claude/skills/pytest-patterns
Command: npx skills add https://github.com/KAIROS7-team3/Final_project --skill pytest-patterns-kairos7-team3

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, pytest-mock, py_trees, doosan-robot2, sqlite3, plc_core, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the complexity and inconsistency in writing pytest-based tests by providing a standardized template, promoting code reuse, and enhancing maintainability.

Core Features & Use Cases

  • Test Structure: Offers a structured template for unit, integration, and golden file regression tests.
  • Fixture Usage: Demonstrates effective use of fixtures for setup and teardown, with different scopes.
  • Parametrization: Explains how to create tests with multiple input cases using parametrization.
  • Mocking: Provides examples of mocking external dependencies to isolate tests.
  • Golden File Regression: Details the process of creating and using golden files for trajectory regression testing.
  • Exception Handling: Shows how to handle exceptions and edge cases in tests.
  • Markers: Uses pytest markers for test categorization and execution filtering.
  • ROS2 Node Testing: Offers guidance on testing ROS2 nodes using launch files and mock nodes.
  • Coverage: Explains how to use coverage tools to ensure code is tested.
  • CI Integration: Provides an example of integrating tests with CI pipelines.
  • Common Pitfalls: Lists common mistakes in testing and how to avoid them.

Quick Start

Run the skill to learn about pytest best practices and implement them in your projects.

Frequently Asked Questions about pytest-patterns

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

FAQPage Schema
How do I structure pytest unit and integration tests for consistency?

To structure pytest unit and integration tests for consistency, use standardized templates that cover fixture usage, parametrization, and mocking to promote code reuse and maintainability across your Python projects.

What is the best way to mock external dependencies in pytest tests?

The best way to mock external dependencies in pytest tests is using the pytest-mock plugin to isolate tests, ensuring that external interactions do not affect test outcomes and improving overall test reliability.

How do I test ROS2 nodes with pytest using launch files?

To test ROS2 nodes with pytest, use launch files alongside mock nodes to simulate the ROS2 environment, allowing you to verify node behavior and interactions in a controlled testing setup.

How does golden file regression testing work for trajectory validation?

Golden file regression testing works by comparing test outputs against pre-approved golden files to validate trajectory data, ensuring that any deviations in trajectory generation are immediately detected during testing.

Can I integrate pytest coverage reports into a CI pipeline?

Yes, you can integrate pytest coverage reports into a CI pipeline by utilizing pytest coverage tools to ensure code is tested, then configuring your CI to execute these tests and fail builds on insufficient coverage.

What are common pitfalls when writing pytest fixtures and parametrized tests?

Common pitfalls when writing pytest fixtures and parametrized tests include improper scope management leading to stale data, and overly complex parametrization causing test redundancy, which can be avoided by following standardized testing patterns.