/** * Pytest lens for Python test running and coverage * * Uses pytest-json-report for JSON output and pytest-cov for coverage. * * @see https://github.com/numirias/pytest-json-report * @see https://pytest-cov.readthedocs.io/ */ import { BaseLens } from '../base/BaseLens.js'; import { LensResult, ExecuteResult } from '../../types/index.js'; /** * Pytest test stage result */ interface PytestStage { /** Stage duration in seconds */ duration: number; /** Stage outcome */ outcome: 'passed' | 'failed' | 'skipped' | 'error'; /** Captured stdout */ stdout?: string; /** Captured stderr */ stderr?: string; /** Error traceback */ traceback?: Array<{ path: string; lineno: number; message: string; }>; /** Long representation of error */ longrepr?: string; /** Crash info */ crash?: { path: string; lineno: number; message: string; }; } /** * Pytest individual test result */ interface PytestTest { /** Test node ID (path::class::method) */ nodeid: string; /** Line number where test starts */ lineno: number; /** Test keywords/markers */ keywords: string[]; /** Overall test outcome */ outcome: 'passed' | 'failed' | 'skipped' | 'xfailed' | 'xpassed' | 'error'; /** Setup stage result */ setup?: PytestStage; /** Call (test execution) stage result */ call?: PytestStage; /** Teardown stage result */ teardown?: PytestStage; /** Custom metadata */ metadata?: Record; } /** * Pytest collector (test discovery) result */ interface PytestCollector { nodeid: string; outcome: 'passed' | 'failed'; result?: Array<{ nodeid: string; type: string; lineno?: number; }>; longrepr?: string; } /** * Pytest summary counts */ interface PytestSummary { collected?: number; passed?: number; failed?: number; xfailed?: number; xpassed?: number; error?: number; skipped?: number; total?: number; } /** * Pytest JSON report format (from pytest-json-report) */ interface PytestJsonReport { /** Report creation timestamp (Unix time) */ created: number; /** Session duration in seconds */ duration: number; /** Exit code */ exitcode: number; /** Root directory */ root: string; /** Environment info */ environment?: Record; /** Test summary counts */ summary: PytestSummary; /** Collector results */ collectors?: PytestCollector[]; /** Individual test results */ tests?: PytestTest[]; /** Warnings */ warnings?: Array<{ filename: string; lineno: number; message: string; category: string; }>; } /** * Lens for Pytest test runner */ export declare class PytestLens extends BaseLens { readonly name = "pytest"; readonly description = "Python test runner"; readonly languages: string[]; readonly supportedTools: string[]; readonly requirements: import("../..").LensRequirements; private pathMapper?; /** * Calculate quality score (0-100) from Pytest results */ static calculateQualityScore(result: LensResult): number; /** * Parse Pytest JSON report output */ parse(output: ExecuteResult): PytestJsonReport; /** * Format Pytest results to standard format */ format(parsed: PytestJsonReport): LensResult; /** * Parse pytest node ID into file path and test name * Format: path/to/test_file.py::TestClass::test_method */ private parseNodeId; /** * Map pytest outcome to standard test status */ private mapOutcome; /** * Extract error message from test result */ private extractErrorMessage; /** * Clean error message (remove ANSI codes, trim) */ private cleanErrorMessage; /** * Truncate message to specified length */ private truncateMessage; /** * Get empty results structure */ private getEmptyResults; /** * Normalize results to ensure all expected fields exist */ private normalizeResults; /** * Get or create path mapper */ private getPathMapper; /** * Override execute to ensure JSON report output */ execute(): Promise; } export {}; //# sourceMappingURL=PytestLens.d.ts.map