Skip to content

test(python): Phase 2/3 tools need additional test coverage #256

@rshade

Description

@rshade

Priority: P1 - High

Problem Statement

New Python Phase 2/3 implementation spans 890 lines but test file is only 475 lines. Project requires 85-90%+ coverage; current ratio suggests insufficient testing for edge cases and error paths.

Missing Test Coverage

Edge Cases Needed

  1. Missing profiler tools - Test behavior when cProfile/py-spy/memray not available
  2. Error paths in venv deletion - Test when venv directory doesn't exist or has permission issues
  3. pyupgrade integration - Test actual pyupgrade output parsing
  4. Compatibility tool - Test vermin output parsing edge cases
  5. Security tool - Test when bandit/pip-audit not installed
  6. Build tool - Test missing build dependencies

Error Path Coverage

  • Invalid directory paths
  • Permission denied scenarios
  • Malformed tool output
  • Network failures for pip-audit
  • Timeout scenarios for long-running profiling

Implementation Guidance

Files to Modify

  • src/__tests__/tools/python-tools.test.ts - Add comprehensive tests

Test Structure

describe('pythonProfile edge cases', () => {
  it('handles missing cProfile gracefully', async () => {
    // Mock command not found
  });
  
  it('validates script path exists', async () => {
    // Test with non-existent script
  });
  
  it('handles profiler timeout', async () => {
    // Test timeout behavior
  });
});

describe('pythonVenv edge cases', () => {
  it('handles deletion of non-existent venv', async () => {
    // Test delete action when venv missing
  });
  
  it('handles permission denied on delete', async () => {
    // Test permission error
  });
});

Acceptance Criteria

  • Coverage ratio improved (target 85-90%+)
  • All error paths tested
  • Missing tool scenarios covered
  • Permission and timeout edge cases tested
  • Tests are fast and well-mocked (per CLAUDE.md standards)
  • make test passes with improved coverage

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-highHigh priority issuespythonPython language supporttechnical-debtTechnical debt and code quality issuestestingTesting infrastructure and test coverage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions