v2.2/skills/v2.2-generate-pytest/SKILL.md
# Skill: /v2.2-generate-pytest **Purpose**: Generate executable pytest code from Software Test Description (STD) and repository context ## Input - **Required**: Path to STD markdown file - **Required**: Path to context.json (from `/v2.2-explore-test-context`) - **Optional**: `--output-dir` - target directory (default: infer from context) ## Output - **File**: `test_<feature_name>.py` - **Location**: Determined by context conventions (e.g., `tests/<domain>/<feature>/`) - **Format**: Executable
npx skillsauth add ruclo/thesis v2.2/skills/v2.2-generate-pytestInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Purpose: Generate executable pytest code from Software Test Description (STD) and repository context
/v2.2-explore-test-context)--output-dir - target directory (default: infer from context)test_<feature_name>.pytests/<domain>/<feature>/)1. READ std_file
- Extract test scenarios
- Parse preconditions
- Identify test data requirements
- Extract acceptance criteria
2. READ context.json
- Load available utilities
- Load fixture patterns
- Load import conventions
- Load naming conventions
1. MAP scenarios to test functions
- test_scenario_1()
- test_scenario_2()
...
2. IDENTIFY required fixtures
- Based on scenario requirements
- Match from context.fixtures
3. PLAN imports
- Use context.imports.common_patterns
- Add scenario-specific imports
- Include utilities from context.utilities
4. DESIGN test data
- Extract from STD requirements
- Use context.constants where applicable
1. WRITE file header
- Module docstring
- Imports (from context)
2. WRITE test functions
FOR each scenario in STD:
- Function signature with fixtures
- Docstring with scenario description
- Precondition setup
- Test execution
- Assertion/validation
- Cleanup (if needed)
- Add pytest markers from context.conventions
3. WRITE helper functions (if needed)
- Only if utility missing in context
- Mark as local helper
- Use base Kubernetes client
4. APPLY conventions
- Follow context.conventions.naming
- Use context.conventions.markers
- Match context.conventions.file_structure
1. VERIFY all imports exist in context
2. VERIFY all fixtures exist in context
3. VERIFY no hallucinated utilities
4. VERIFY proper pytest structure
# -*- coding: utf-8 -*-
"""
{feature_name} Tests
{brief_description}
Based on: {std_file}
"""
import logging
import pytest
# Imports from context.json
{context_imports}
LOGGER = logging.getLogger(__name__)
{fixture_definitions_if_needed}
@pytest.mark.polarion("{polarion_id}")
@pytest.mark.{tier}
def test_{scenario_name}({fixtures}):
"""
{scenario_description}
Steps:
{test_steps}
Expected:
{expected_outcome}
"""
LOGGER.info(f"Starting test: {scenario_name}")
# Preconditions
{precondition_code}
# Test execution
{test_code}
# Validation
{assertion_code}
# Cleanup (if needed)
{cleanup_code}
context.jsoncontext.conventions.namingcontext.fixtures as discoveredcontext.imports patternscontext.conventions.file_structure1. PARSE std_file → scenarios[]
2. PARSE context.json → {utilities, fixtures, imports, conventions}
3. FOR each scenario in scenarios:
a. EXTRACT requirements
b. MAP to fixtures from context
c. SELECT utilities from context
d. DESIGN test function
4. GENERATE imports (from context.imports)
5. GENERATE test functions
6. VERIFY no hallucinated code
7. WRITE to output file
8. RETURN file path
Given STD with 2 scenarios:
# -*- coding: utf-8 -*-
"""
VM Reset Tests
Tests for Force/Hard Reset functionality
Based on: std_vm_reset.md
"""
import logging
import pytest
from ocp_resources.virtual_machine import VirtualMachine
from utilities.virt import VirtualMachineForTests, wait_for_vm_running
LOGGER = logging.getLogger(__name__)
@pytest.mark.polarion("CNV-12345-01")
@pytest.mark.tier1
def test_reset_running_vmi_via_api(namespace, admin_client):
"""
Reset running VMI via API and verify guest reboots
Steps:
1. Create and start VM
2. Record boot time
3. Call reset API
4. Verify boot time changed
Expected:
- VM reboots without pod rescheduling
- Boot time is updated
"""
LOGGER.info("Creating VM for reset test")
vm = VirtualMachineForTests(
name="test-reset-vm",
namespace=namespace.name,
client=admin_client
)
vm.deploy(wait=True)
wait_for_vm_running(vm)
initial_boot_time = vm.instance.status.boot_time
LOGGER.info(f"Initial boot time: {initial_boot_time}")
LOGGER.info("Calling reset API")
vm.instance.reset()
wait_for_vm_running(vm)
new_boot_time = vm.instance.status.boot_time
assert new_boot_time != initial_boot_time, "Boot time should change after reset"
LOGGER.info("Reset successful - boot time updated")
@pytest.mark.polarion("CNV-12345-02")
@pytest.mark.tier1
def test_reset_via_virtctl(namespace, admin_client):
"""
Reset running VMI via virtctl command
Steps:
1. Create and start VM
2. Execute virtctl reset command
3. Verify VM reboots
Expected:
- virtctl reset succeeds
- VM reboots successfully
"""
# Implementation here...
# Standard usage
/v2.2-generate-pytest std_vm_reset.md context.json
# Custom output directory
/v2.2-generate-pytest std_feature.md context.json --output-dir tests/custom/
# Output: tests/virt/lifecycle/test_vm_reset.py
If context.json is missing/invalid:
ERROR: context.json not found or invalid
HINT: Run `/v2.2-explore-test-context` first to generate context
If STD is malformed:
ERROR: Could not parse STD file
HINT: Ensure STD follows expected structure
If utility is missing from context:
WARNING: Utility 'FooHelper' not found in context
ACTION: Implementing locally using base Kubernetes client
Medium-High - Can be used for:
/v2.2-generate-std or manual)/v2.2-explore-test-context)development
# Skill: /v3-test-heal **Purpose**: Self-healing loop that runs the generated test against a real cluster, analyzes failures from logs, consults documentation and repository code to fix issues, and records lessons learned in GRAVEYARD.md ## Input - **Required**: Path to the generated test file (e.g., `tests/virt/cluster/test_vnc_screenshot.py`) - **Optional**: `--max-iterations N` - Maximum heal attempts (default: 3) ## Output - **Modified File**: Test file edited in-place with fixes applied
development
# Skill: /v3-pyright-heal **Purpose**: Universal Python type checker and self-healing fixer for ANY Python file ## Input - **Required**: Path to Python file (`.py` or `.ipynb`) - **Optional**: `--max-iterations N` - Maximum fix attempts (default: 10) - **Optional**: `--strict` - Use strict type checking mode ## Output - **Modified File**: Same file, edited in-place - **Exit Code**: 0 if clean, 1 if max iterations reached with errors - **Log**: Summary of fixes applied ## Implementation ###
development
# Skill: /v3-graveyard-verify **Purpose**: Post-generation verification that cross-references the generated test code against GRAVEYARD.md to catch known mistakes before runtime ## Input - **Required**: Path to the generated test file ## Output - **Modified File**: Test file edited in-place with fixes for any GRAVEYARD violations found - **Report**: Summary of violations found and fixes applied (conversational output) ## Role You are a **code reviewer specializing in catching known mistakes*
development
# Skill: /v3-generate-std > _This document was created with the assistance of Claude (Anthropic)._ You are a Senior QE Engineer responsible for creating Software Test Descriptions (STDs) for OpenShift Virtualization. Given a high-level Software Test Plan (STP), generate test code stubs with comprehensive docstrings that serve as the STD. **Important:** The generated test code should follow the structure and patterns from the [openshift-virtualization-tests](https://github.com/RedHatQE/openshi