Skip to content

Implement Skip Decorator Abuse Detection #13

Description

@frankbria

Summary

Create automated detection for @pytest.mark.skip decorators that AI agents add to circumvent failing tests.

Problem

AI agents sometimes add @Skip decorators to failing tests instead of fixing them, which:

  • Hides real bugs
  • Degrades test suite value
  • Creates technical debt
  • Violates TDD principles

Tasks

1. Create Detection Script

  • Create tools/detect-skip-abuse.py
  • Parse Python AST to find skip decorators
  • Check for justification comments
  • Report file, line, and function name

2. Validation Logic

  • Detect @skip, @skipif, @pytest.mark.skip
  • Check for skip reason strings
  • Flag skips with weak justifications
  • Handle false positives gracefully

3. Integration

  • Add to pre-commit hooks
  • Make script executable
  • Test with various skip patterns
  • Add to CI/CD pipeline

4. Documentation

  • Document why skips are forbidden
  • Explain approval process for legitimate skips
  • Add examples of proper test fixing

Test Cases

# Should detect these:
@pytest.mark.skip  # No reason
@pytest.mark.skip("TODO")  # Weak reason
@skip  # Bare decorator

# Should allow (if policy changed):
@pytest.mark.skip(reason="External API unavailable in CI")

Success Criteria

  • Detects all skip decorator variations
  • Pre-commit hook blocks commits with skips
  • Clear error messages explain violations
  • No false positives on legitimate code

Technical Approach

Use Python's ast module to parse test files and walk the AST looking for skip decorators. This is more reliable than regex matching.

Dependencies

Estimated Effort: 3-4 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions