test-refactoring

Refactor Python test suites using pytest.mark.parametrize and modularization.

1|Updated Jul 20, 2022
One-click install
npx skills add https://github.com/fruch/coodie --skill test-refactoring
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-refactoring
Source: https://github.com/fruch/coodie/tree/main/.github/skills/test-refactoring
Command: npx skills add https://github.com/fruch/coodie --skill test-refactoring

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenges of overly large, duplicated, and hard-to-maintain Python test suites, making them more readable, efficient, and easier to manage.

Core Features & Use Cases

  • Parametrization: Consolidates repetitive test functions into single, parametrized tests using pytest.mark.parametrize.
  • Sync/Async Deduplication: Merges mirrored sync and async test classes into a single test function using helpers like _maybe_await.
  • Modularization: Guides the splitting of large test files into smaller, focused modules based on feature areas.
  • Use Case: Refactor a test file with over 700 lines and many copy-pasted test functions into a more maintainable structure with parametrized tests and smaller modules.

Quick Start

Use the test-refactoring skill to refactor the file 'tests/test_cql_builder.py' by applying parametrization patterns.

Frequently Asked Questions about test-refactoring

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

FAQPage Schema
How do I reduce duplication in Python pytest test suites?▼

You can reduce duplication in Python pytest test suites by consolidating repetitive test functions into single tests using pytest.mark.parametrize, and merging mirrored sync and async test classes with helpers like _maybe_await.

What is the best way to split a monolithic Python test file?▼

The best way to split a monolithic Python test file is modularization, which involves dividing large test files into smaller, focused modules based on distinct feature areas to improve maintainability.

Can I combine sync and async test cases in pytest?▼

Yes, you can combine sync and async test cases in pytest by deduplicating mirrored test classes into a single test function using specific helper functions like _maybe_await.

How does pytest.mark.parametrize help with test refactoring?▼

pytest.mark.parametrize helps with test refactoring by allowing you to parametrize tests, which consolidates multiple repetitive, copy-pasted test functions into a single, maintainable test structure.

When should I refactor large Python test files?▼

You should refactor large Python test files when they become overly large, duplicated, and hard to maintain, such as when a file exceeds 700 lines with many copy-pasted test functions.

Are there limitations to using pytest parametrization for deduplication?▼

When using pytest parametrization for deduplication, you must adhere to specific refactoring principles and workflows to ensure effective implementation and maintain readability across split modules.