firecrown.fctools.coverage_to_tsv ================================= .. py:module:: firecrown.fctools.coverage_to_tsv .. autoapi-nested-parse:: Convert pytest-cov JSON coverage data to TSV format. This script reads a coverage.json file generated by pytest-cov and extracts key information into a tab-separated values (TSV) file for easy analysis. Attributes ---------- .. autoapisummary:: firecrown.fctools.coverage_to_tsv.app Classes ------- .. autoapisummary:: firecrown.fctools.coverage_to_tsv.CoverageRecord Functions --------- .. autoapisummary:: firecrown.fctools.coverage_to_tsv.parse_timing_data firecrown.fctools.coverage_to_tsv.match_test_to_function firecrown.fctools.coverage_to_tsv.extract_coverage_data firecrown.fctools.coverage_to_tsv.write_tsv_file firecrown.fctools.coverage_to_tsv.main Module Contents --------------- .. py:class:: CoverageRecord Bases: :py:obj:`NamedTuple` .. autoapi-inheritance-diagram:: firecrown.fctools.coverage_to_tsv.CoverageRecord :parts: 1 Structure for holding coverage data for a single function. .. py:attribute:: file_path :type: str .. py:attribute:: function_name :type: str .. py:attribute:: covered_lines :type: int .. py:attribute:: total_statements :type: int .. py:attribute:: percent_covered :type: float .. py:attribute:: missing_lines :type: int .. py:attribute:: excluded_lines :type: int .. py:attribute:: num_branches :type: int .. py:attribute:: covered_branches :type: int .. py:attribute:: missing_branches :type: int .. py:attribute:: num_partial_branches :type: int .. py:attribute:: percent_covered_display :type: str .. py:attribute:: file_total_statements :type: int .. py:attribute:: file_covered_lines :type: int .. py:attribute:: file_percent_covered :type: float .. py:attribute:: test_duration :type: float | None :value: None .. py:function:: parse_timing_data(console, timing_file) Parse timing data from pytest --durations output or JSON file. Args: console: The rich console object. timing_file: Path to timing data file (JSON or text output) Returns: Dictionary mapping test names to duration in seconds .. py:function:: match_test_to_function(test_name, function_name, file_path) Try to match a test name to a function for timing correlation. Args: test_name: Full test identifier (like "tests/test_mod.py::test_method") function_name: Function name from coverage data file_path: File path from coverage data Returns: Relevance score (0.0 to 1.0) for the match .. py:function:: extract_coverage_data(coverage_data, timing_data = None) Extract coverage information from the JSON data, optionally including timing. Args: coverage_data: The loaded JSON coverage data timing_data: Optional dictionary of test timing data Returns: List of CoverageRecord objects containing detailed coverage information .. py:function:: write_tsv_file(data, output_file) Write the extracted data to a TSV file. Args: data: List of CoverageRecord objects with coverage data output_file: Path to output TSV file .. py:data:: app .. py:function:: main(input_file = typer.Argument(..., exists=True, file_okay=True, dir_okay=False, readable=True, resolve_path=True, help='Path to the input JSON coverage file'), output_file = typer.Argument('coverage_data.tsv', help='Path to the output TSV file', writable=True, resolve_path=True), timing = typer.Option(None, '--timing', exists=True, file_okay=True, dir_okay=False, readable=True, resolve_path=True, help='Optional path to timing data file (JSON from pytest-json-report or text from pytest --durations)')) Convert pytest-cov JSON coverage data to TSV format. This tool reads a JSON file containing pytest-cov coverage data and converts it to a tab-separated values (TSV) format. The output includes details about file coverage, function coverage, and missing line information. Examples: coverage_to_tsv.py coverage.json coverage_to_tsv.py coverage.json output.tsv coverage_to_tsv.py coverage.json output.tsv --timing timing.txt coverage_to_tsv.py /path/to/coverage.json /path/to/output.tsv \\ --timing timing.json