### Install CoverUp Source: https://context7.com/plasma-umass/coverup/llms.txt Install CoverUp using pip. This command installs the package and its dependencies. ```bash pip install coverup ``` -------------------------------- ### Install CoverUp using pip Source: https://github.com/plasma-umass/coverup/blob/main/README.md Install CoverUp using pip. Ensure you are using Python 3. ```shell python3 -m pip install coverup ``` -------------------------------- ### Example: CoverUp increasing Flask coverage Source: https://github.com/plasma-umass/coverup/blob/main/README.md Demonstrates running CoverUp on the Flask package, showing the initial coverage measurement and the final increased coverage after test generation. The output includes progress indicators and cost estimation. ```shell $ coverup --package src/flask --tests tests Measuring coverage... 90.9% Prompting gpt-4o-2024-05-13 for tests to increase coverage... (in the following, G=good, F=failed, U=useless and R=retry) 100%|███████████████████████████████████████| 92/92 [01:01<00:00, 1.50it/s, G=55, F=122, U=20, R=0, cost=~$4.19] Measuring coverage... 94.4% $ ``` -------------------------------- ### Implement Custom Prompter for Test Generation Source: https://context7.com/plasma-umass/coverup/llms.txt Extend the Prompter abstract base class to define custom logic for generating LLM prompts. Implement initial_prompt, error_prompt, and missing_coverage_prompt methods to guide test generation based on code segments and errors. Requires importing Prompter, mk_message, and CodeSegment. ```python from coverup.prompt.prompter import Prompter, mk_message from coverup.segment import CodeSegment import typing as T class CustomPrompter(Prompter): """Custom prompter with domain-specific instructions.""" def initial_prompt(self, segment: CodeSegment) -> T.List[dict]: """Generate the initial prompt for a code segment.""" return [ mk_message(f""" You are a senior Python developer specializing in test-driven development. Analyze the following code from {segment.filename} that lacks test coverage: {segment.lines_branches_missing_do()} are not currently tested. ```python {segment.get_excerpt()} ``` Requirements: 1. Write pytest tests that execute all missing lines and branches 2. Include edge cases and error conditions 3. Use fixtures where appropriate 4. Add assertions verifying postconditions 5. Clean up any state changes using monkeypatch or mocks Respond with complete Python test code in ```python blocks. """) ] def error_prompt(self, segment: CodeSegment, error: str) -> T.List[dict] | None: """Generate prompt when a test fails.""" return [ mk_message(f""" The test failed with the following error: {error} Please fix the test and provide the complete corrected code. """) ] def missing_coverage_prompt( self, segment: CodeSegment, missing_lines: set, missing_branches: set ) -> T.List[dict] | None: """Generate prompt when test doesn't improve coverage enough.""" from coverup.utils import lines_branches_do return [ mk_message(f""" The test runs but doesn't cover all required code. Still missing: {lines_branches_do(missing_lines, set(), missing_branches)} Modify the test to execute these remaining lines/branches. Provide the complete updated test code. """) ] def get_functions(self) -> T.List[T.Callable]: """Return list of functions available to the LLM.""" return [] # Or return [self.custom_lookup_function] # Usage with CoverUp's registry # prompter = CustomPrompter(cmd_args=args) ``` -------------------------------- ### Get Summary Coverage Percentage Source: https://context7.com/plasma-umass/coverup/llms.txt Extracts and formats the summary coverage percentage from coverage data. This is useful for reporting overall test coverage. ```python from coverup.utils import summary_coverage coverage_data = { "summary": {"percent_covered": 85.5}, "files": {...} } print(summary_coverage(coverage_data, sources=[])) ``` -------------------------------- ### Get Formatted Code with Imports Source: https://context7.com/plasma-umass/coverup/llms.txt Retrieves formatted code for a specific module, function, or method, including relevant import statements. Useful for understanding code structure and dependencies. ```python info = get_info( module, name="Calculator.divide", # Can be "ClassName.method" or just "function_name" line=50, # Optional: line number for context (helps with local imports) generate_imports=True # Include relevant import statements ) if info: print(info) ``` -------------------------------- ### Get Global Imports for a Node Source: https://context7.com/plasma-umass/coverup/llms.txt Retrieves global import statements that define names used within a specific Abstract Syntax Tree (AST) node, such as a class definition. This helps in understanding the scope and dependencies of code elements. ```python class_node = next( node for node in ast.walk(module) if isinstance(node, ast.ClassDef) and node.name == "Calculator" ) imports = get_global_imports(module, class_node) for imp in imports: print(ast.unparse(imp)) ``` -------------------------------- ### Get Missing Coverage Segments Source: https://context7.com/plasma-umass/coverup/llms.txt Use `get_missing_coverage` to parse coverage data and identify code segments needing more tests. This function requires `measure_suite_coverage` to be run first to obtain the coverage data. ```python from pathlib import Path from coverup.segment import get_missing_coverage, CodeSegment from coverup.testrunner import measure_suite_coverage # First, measure existing coverage coverage = measure_suite_coverage( tests_dir=Path("tests"), source_dir=Path("src/mypackage") ) ``` -------------------------------- ### Instantiate and Use CodeSegment Class Source: https://context7.com/plasma-umass/coverup/llms.txt Demonstrates how to create a `CodeSegment` object and access its properties and methods. This includes identifying the segment, counting missing items, generating descriptions, and retrieving code excerpts. ```python from pathlib import Path from coverup.segment import CodeSegment # CodeSegment is typically created by get_missing_coverage(), but can be instantiated directly segment = CodeSegment( filename=Path("src/mypackage/calculator.py"), name="divide", # Function or class name begin=25, # Start line (1-indexed) end=35, # End line (exclusive) lines_of_interest={27, 28, 30, 31}, # Lines with coverage relevance missing_lines={28, 30, 31}, # Lines not executed executed_lines={25, 26, 27, 29}, # Lines already covered missing_branches={(27, 28), (27, 30)}, # Uncovered branch transitions context=[(20, 25)], # Enclosing context (e.g., class definition) imports=["from decimal import Decimal"] # Required imports ) # Key properties and methods print(f"Segment identifier: {segment.identify()}") # Output: "src/mypackage/calculator.py:25-34" print(f"Missing items count: {segment.missing_count()}") # Output: 5 (3 lines + 2 branches) # Get description for prompts print(segment.lines_branches_missing_do()) # Output: "lines 28, 30-31 and branches 27->28, 27->30 do not execute" # Get formatted code excerpt excerpt = segment.get_excerpt(tag_lines=True, add_imports=True) print(excerpt) # Output: # from decimal import Decimal # class Calculator: # 25: def divide(self, a, b): # 26: if b == 0: # 27: raise ZeroDivisionError("Cannot divide by zero") # 28: if isinstance(a, Decimal): # ... # Check segment completion status print(f"Path: {segment.path}") # Resolved absolute path print(f"Filename: {segment.filename}") # Original filename ``` -------------------------------- ### Basic CoverUp CLI Usage Source: https://context7.com/plasma-umass/coverup/llms.txt Run CoverUp from the command line to generate tests for your Python package. Specify the package source directory and the tests directory. ```bash # Basic usage with a package coverup --package-dir src/mypackage --tests-dir tests ``` ```bash # Example with Flask package - generates tests and shows progress coverup --package src/flask --tests tests # Output: # Measuring coverage... 90.9% # Prompting gpt-4o-2024-05-13 for tests to increase coverage... # (in the following, G=good, F=failed, U=useless and R=retry) # 100%|███████████████████████████████████████| 92/92 [01:01<00:00, 1.50it/s, G=55, F=122, U=20, R=0, cost=~$4.19] # Measuring coverage... 94.4% ``` -------------------------------- ### Run CoverUp on a Package Source: https://github.com/plasma-umass/coverup/blob/main/README.md Execute CoverUp to generate tests for a specified package. CoverUp will create new test files named test_coverup_N.py in the tests directory. ```shell coverup --package src/mymod --tests tests ``` -------------------------------- ### Specify LLM Model and API Key Source: https://context7.com/plasma-umass/coverup/llms.txt Configure CoverUp to use specific LLM models like OpenAI's GPT-4o or Anthropic's Claude. Ensure the corresponding API key is set as an environment variable. ```bash # Specify model and API key (set environment variable first) export OPENAI_API_KEY=sk-your-api-key coverup --package-dir src/myapp --tests-dir tests --model gpt-4o ``` ```bash # Use Anthropic Claude model export ANTHROPIC_API_KEY=your-anthropic-key coverup --package-dir src/myapp --tests-dir tests --model anthropic/claude-3-sonnet-20240229 ``` ```bash # Use AWS Bedrock export AWS_ACCESS_KEY_ID=your-key-id export AWS_SECRET_ACCESS_KEY=your-secret export AWS_REGION_NAME=us-west-2 coverup --package-dir src/myapp --tests-dir tests --model anthropic.claude-3-5-sonnet-20241022-v2:0 ``` -------------------------------- ### Manage CoverUp State and Checkpoints Source: https://context7.com/plasma-umass/coverup/llms.txt Utilize the State class to manage CoverUp's execution state, including coverage data, costs, and counters. Supports saving and loading checkpoints for resuming interrupted test generation sessions. Requires importing State and measure_suite_coverage. ```python import json from pathlib import Path from coverup.coverup import State from coverup.testrunner import measure_suite_coverage # Measure initial coverage initial_coverage = measure_suite_coverage( tests_dir=Path("tests"), source_dir=Path("src/mypackage") ) # Create state with initial coverage state = State(initial_coverage) # Track progress during test generation state.add_cost(0.05) # Track API costs state.inc_counter('G') # Increment 'good' test counter state.inc_counter('F') # Increment 'failed' test counter # Mark segments as completed class MockSegment: def __init__(self, path, begin, end): self.path = Path(path).resolve() self.begin = begin self.end = end seg = MockSegment("src/mypackage/utils.py", 10, 25) state.mark_done(seg) print(f"Segment done: {state.is_done(seg)}") # True # Save checkpoint checkpoint_file = Path("coverup-checkpoint.json") state.save_checkpoint(checkpoint_file) # Later: resume from checkpoint resumed_state = State.load_checkpoint(checkpoint_file) if resumed_state: print(f"Resumed with coverage: {resumed_state.get_initial_coverage()['summary']['percent_covered']:.1f}%") # Check if segments were already processed print(f"Segment already done: {resumed_state.is_done(seg)}") # Checkpoint file structure: # { # "version": 2, # "done": { # "/abs/path/to/utils.py": [[10, 25], [30, 45]], # ... # }, # "cost": 1.25, # "counters": {"G": 10, "F": 5, "U": 3, "R": 2}, # "coverage": {...}, # "final_coverage": {...} # Added when complete # } ``` -------------------------------- ### Set OpenAI API Key Environment Variable Source: https://github.com/plasma-umass/coverup/blob/main/README.md Set the OPENAI_API_KEY environment variable with your OpenAI API key. Ensure your OpenAI account has a positive balance. ```shell export OPENAI_API_KEY=<...your-api-key...> ``` -------------------------------- ### Adjust Concurrency and Retry Settings Source: https://context7.com/plasma-umass/coverup/llms.txt Customize CoverUp's behavior regarding parallel requests and test generation retries. Adjust --max-concurrency, --max-attempts, and --max-backoff for performance tuning. ```bash # Adjust concurrency and retry settings coverup --package-dir src/myapp --tests-dir tests \ --max-concurrency 20 \ --max-attempts 5 \ --max-backoff 128 ``` -------------------------------- ### Generate Human-Readable Coverage Description Source: https://context7.com/plasma-umass/coverup/llms.txt Creates a descriptive string summarizing missing and executed lines and branches. This function helps in quickly understanding code coverage status. ```python from coverup.utils import lines_branches_do missing_lines = {15, 16, 17} executed_lines = {10, 11, 12} missing_branches = {(12, 15), (12, 18)} description = lines_branches_do(missing_lines, executed_lines, missing_branches) print(description) ``` -------------------------------- ### Enable Checkpoint for Resuming Sessions Source: https://context7.com/plasma-umass/coverup/llms.txt Use the --checkpoint option to save the state of a CoverUp session. This allows you to resume interrupted test generation processes later. ```bash # Enable checkpoint for resuming interrupted sessions coverup --package-dir src/myapp --tests-dir tests --checkpoint coverup.ckpt ``` -------------------------------- ### Parse Python Source Files with coverup.codeinfo Source: https://context7.com/plasma-umass/coverup/llms.txt Use utilities from the `codeinfo` module to parse Python source files and extract structural information. Functions like `parse_file` help in analyzing code for context-aware prompting. Requires importing Path, parse_file, get_info, get_global_imports, and ast. ```python from pathlib import Path from coverup.codeinfo import parse_file, get_info, get_global_imports import ast # Parse a Python source file module = parse_file(Path("src/mypackage/calculator.py")) # Get information about a symbol (class, function, or method) ``` -------------------------------- ### Format Branch Coverage Source: https://context7.com/plasma-umass/coverup/llms.txt Formats branch coverage data, represented as tuples of (from_line, to_line), into a human-readable string format. '0' for to_line indicates an exit branch. ```python from coverup.utils import format_branches branches = {(10, 11), (10, 15), (20, 0)} # (from_line, to_line), 0 = exit formatted_branches = list(format_branches(branches)) print(formatted_branches) ``` -------------------------------- ### Process Specific Source Files Source: https://context7.com/plasma-umass/coverup/llms.txt Limit CoverUp's test generation to specific Python files within your package. This is useful for targeted updates or when working on specific modules. ```bash # Process specific source files only coverup --package-dir src/myapp --tests-dir tests src/myapp/utils.py src/myapp/core.py ``` -------------------------------- ### Measure Suite Coverage with Coverup Source: https://context7.com/plasma-umass/coverup/llms.txt Use `measure_suite_coverage` to run pytest on a test directory and collect line and branch coverage. Ensure necessary imports are present. Coverage data is returned as a dictionary. ```python from pathlib import Path from coverup.testrunner import measure_suite_coverage # Measure coverage for a test suite coverage = measure_suite_coverage( tests_dir=Path("tests"), source_dir=Path("src/mypackage"), pytest_args="-v --tb=short", isolate_tests=True, # Run tests in isolation to avoid state pollution branch_coverage=True # Include branch coverage (default: True) ) # Coverage result structure # { # "meta": {...}, # "files": { # "src/mypackage/module.py": { # "executed_lines": [1, 2, 3, 5, 10, 11], # "missing_lines": [7, 8, 15, 16], # "executed_branches": [[5, 6], [10, 11]], # "missing_branches": [[5, 7], [10, 15]] # }, # ... # }, # "summary": { # "percent_covered": 85.5 # } # } # Access coverage for a specific file file_cov = coverage['files'].get('src/mypackage/module.py') if file_cov: print(f"Executed lines: {file_cov['executed_lines']}") print(f"Missing lines: {file_cov['missing_lines']}") print(f"Missing branches: {file_cov.get('missing_branches', [])}") # Get summary coverage percentage print(f"Total coverage: {coverage['summary']['percent_covered']:.1f}%") ``` -------------------------------- ### Measure Single Test Coverage Asynchronously Source: https://context7.com/plasma-umass/coverup/llms.txt The `measure_test_coverage` async function executes a single test string and returns its coverage. It requires imports for `asyncio` and `Path`. A `log_write` callback can be provided for logging. ```python import asyncio from pathlib import Path from coverup.testrunner import measure_test_coverage async def validate_test(): test_code = ''' import pytest from mypackage.utils import calculate_sum def test_calculate_sum_basic(): assert calculate_sum(1, 2) == 3 assert calculate_sum(-1, 1) == 0 assert calculate_sum(0, 0) == 0 def test_calculate_sum_edge_cases(): assert calculate_sum(float('inf'), 1) == float('inf') with pytest.raises(TypeError): calculate_sum("a", "b") ''' coverage = await measure_test_coverage( test=test_code, tests_dir=Path("tests"), pytest_args="--tb=short", isolate_tests=False, branch_coverage=True, log_write=lambda msg: print(f"[LOG] {msg}") ) # Check if the test covers specific lines if 'mypackage/utils.py' in coverage['files']: file_cov = coverage['files']['mypackage/utils.py'] print(f"Lines executed: {file_cov['executed_lines']}") print(f"Branches executed: {file_cov.get('executed_branches', [])}") return coverage # Run the async function coverage = asyncio.run(validate_test()) ``` -------------------------------- ### measure_suite_coverage Function Source: https://context7.com/plasma-umass/coverup/llms.txt Measures the coverage of an entire test suite and returns detailed coverage data for each source file. ```APIDOC ## measure_suite_coverage Function ### Description Measure the coverage of an entire test suite and return detailed coverage data. The `measure_suite_coverage` function runs pytest on a test directory with SlipCover instrumentation to collect line and branch coverage information. It returns a dictionary containing coverage data for each source file. ### Method `measure_suite_coverage` ### Parameters - **tests_dir** (Path) - Required - The directory containing the tests. - **source_dir** (Path) - Required - The directory containing the source code. - **pytest_args** (str, optional) - Arguments to pass to pytest. - **isolate_tests** (bool, optional) - Run tests in isolation to avoid state pollution. Defaults to True. - **branch_coverage** (bool, optional) - Include branch coverage. Defaults to True. ### Response Example ```json { "meta": {}, "files": { "src/mypackage/module.py": { "executed_lines": [1, 2, 3, 5, 10, 11], "missing_lines": [7, 8, 15, 16], "executed_branches": [[5, 6], [10, 11]], "missing_branches": [[5, 7], [10, 15]] } }, "summary": { "percent_covered": 85.5 } } ``` ``` -------------------------------- ### Generate Pytest Tests with Chatter Source: https://context7.com/plasma-umass/coverup/llms.txt Use the Chatter class to send messages to an LLM and generate pytest tests. Configure model settings, callbacks for cost tracking and logging, and handle potential errors. ```python import asyncio from coverup.llm import Chatter, ChatterError async def generate_test_with_llm(): try: # Initialize chatter with a model chatter = Chatter(model="gpt-4o") # Configure settings chatter.set_model_temperature(0.2) chatter.set_max_backoff(64) # Max seconds for exponential backoff chatter.set_token_rate_limit((30_000_000, 60)) # tokens per minute # Set up callbacks for logging and cost tracking total_cost = 0.0 def add_cost(cost): nonlocal total_cost total_cost += cost print(f"Current total cost: ${total_cost:.4f}") chatter.set_add_cost(add_cost) chatter.set_log_msg(lambda ctx, msg: print(f"[{ctx}] {msg}")) chatter.set_signal_retry(lambda: print("Retrying...")) # Send a chat message messages = [ { "role": "user", "content": """Create a pytest test for this function: ```python def factorial(n): if n < 0: raise ValueError("n must be non-negative") if n <= 1: return 1 return n * factorial(n - 1) ``` Ensure the test covers the error case and edge cases."" } ] response = await chatter.chat(messages, ctx="factorial_test") if response: content = response["choices"][0]["message"]["content"] print(f"Generated test:\n{content}") print(f"Total cost: ${total_cost:.4f}") return response except ChatterError as e: print(f"Configuration error: {e}") return None # Run the async function response = asyncio.run(generate_test_with_llm()) ``` -------------------------------- ### Format Line Numbers into Ranges Source: https://context7.com/plasma-umass/coverup/llms.txt Formats a set of line numbers into human-readable ranges, excluding specified negative lines that might break the sequence. Useful for displaying coverage information concisely. ```python from coverup.utils import format_ranges lines = {1, 2, 3, 5, 10, 11, 12, 15} negative = {4} # Lines that break ranges formatted = format_ranges(lines, negative) print(formatted) ``` -------------------------------- ### Async Subprocess Execution Source: https://context7.com/plasma-umass/coverup/llms.txt Executes a command in a subprocess asynchronously with options for checking the return code and setting a timeout. Useful for running external commands within an async Python application. ```python import asyncio from coverup.utils import subprocess_run async def run_command(): result = await subprocess_run( ["python", "-c", "print('Hello')"], check=True, timeout=30 # seconds ) print(f"Return code: {result.returncode}") print(f"Output: {result.stdout.decode()}") return result asyncio.run(run_command()) ``` -------------------------------- ### Process Code Segments with Missing Coverage Source: https://context7.com/plasma-umass/coverup/llms.txt Iterates through code segments identified by `get_missing_coverage`. Sorts segments by the number of missing items and prints detailed information including filename, function/class name, line numbers, missing lines/branches, and a code excerpt. ```python segments = get_missing_coverage( coverage, line_limit=50 # Keep segments at or below 50 lines ) # Sort by number of missing items (most uncovered first) segments.sort(key=lambda seg: seg.missing_count(), reverse=True) # Process each segment for seg in segments: print(f"\n{'='*60}") print(f"File: {seg.filename}") print(f"Function/Class: {seg.name}") print(f"Lines: {seg.begin}-{seg.end-1}") print(f"Missing lines: {sorted(seg.missing_lines)}") print(f"Missing branches: {list(seg.missing_branches)}") print(f"Total missing: {seg.missing_count()}") # Get code excerpt with line numbers for missing coverage excerpt = seg.get_excerpt(tag_lines=True, add_imports=True) print(f"\nCode excerpt:\n{excerpt}") # Get human-readable description of what's missing description = seg.lines_branches_missing_do() print(f"Description: {description}") ``` -------------------------------- ### Chatter Function Calling for Symbol Information Source: https://context7.com/plasma-umass/coverup/llms.txt Register custom Python functions with JSON schemas in their docstrings to allow the LLM to call them during test generation. The Chatter class automatically handles function calls. ```python import asyncio import json from coverup.llm import Chatter def get_symbol_info(*, ctx, name: str) -> str: """ { "name": "get_symbol_info", "description": "Returns information about a Python symbol (class, function, or method).", "parameters": { "type": "object", "properties": { "name": { "type": "string", "description": "Symbol name, e.g., 'MyClass' or 'MyClass.method'" } }, "required": ["name"] } } """ # Simulated symbol lookup symbols = { "Calculator": "class Calculator:\n def add(self, a, b): return a + b\n def subtract(self, a, b): return a - b", "Calculator.add": "def add(self, a, b):\n '''Add two numbers.'''\n return a + b" } return symbols.get(name, f"Symbol '{name}' not found") async def chat_with_functions(): chatter = Chatter(model="gpt-4o") # Register the function - LLM can now call it chatter.add_function(get_symbol_info) messages = [{ "role": "user", "content": "Write a test for Calculator.add. Use get_symbol_info to learn about the method first." }] # The chat method automatically handles function calls response = await chatter.chat(messages, ctx="calc_test") if response: print(response["choices"][0]["message"]["content"]) return response asyncio.run(chat_with_functions()) ``` -------------------------------- ### Control Test Pollution Detection Source: https://context7.com/plasma-umass/coverup/llms.txt Enable or disable test isolation to prevent state pollution between tests. Use --disable-polluting to enforce stricter isolation. ```bash # Enable test pollution detection and disable polluting tests coverup --package-dir src/myapp --tests-dir tests --disable-polluting ``` -------------------------------- ### measure_test_coverage Function Source: https://context7.com/plasma-umass/coverup/llms.txt Measures coverage obtained by running a single test. ```APIDOC ## measure_test_coverage Function ### Description Measure coverage obtained by running a single test. The `measure_test_coverage` function is an async function that executes a single test string and returns the coverage it achieves. This is used internally by CoverUp to validate LLM-generated tests. ### Method `measure_test_coverage` (async) ### Parameters - **test** (str) - Required - The test code to execute. - **tests_dir** (Path) - Required - The directory containing the tests. - **pytest_args** (str, optional) - Arguments to pass to pytest. - **isolate_tests** (bool, optional) - Run tests in isolation to avoid state pollution. Defaults to False. - **branch_coverage** (bool, optional) - Include branch coverage. Defaults to True. - **log_write** (callable, optional) - A callback function to log messages. ### Response Example ```json { "meta": {}, "files": { "mypackage/utils.py": { "executed_lines": [1, 2, 3, 5, 10, 11], "missing_lines": [7, 8, 15, 16], "executed_branches": [[5, 6], [10, 11]], "missing_branches": [[5, 7], [10, 15]] } }, "summary": { "percent_covered": 90.0 } } ``` ``` -------------------------------- ### Pass Additional Pytest Arguments Source: https://context7.com/plasma-umass/coverup/llms.txt Pass custom arguments directly to the pytest runner used by CoverUp. This allows for fine-grained control over test execution, such as verbosity or traceback formatting. ```bash # Pass additional pytest arguments coverup --package-dir src/myapp --tests-dir tests --pytest-args "-v --tb=short" ``` -------------------------------- ### get_missing_coverage Function Source: https://context7.com/plasma-umass/coverup/llms.txt Parses coverage data to identify code segments that need additional tests. ```APIDOC ## get_missing_coverage Function ### Description Parse coverage data to identify code segments that need additional tests. The `get_missing_coverage` function processes SlipCover coverage output and returns a list of `CodeSegment` objects representing functions, methods, or classes that have uncovered lines or branches. It intelligently groups missing coverage into logical code units. ### Method `get_missing_coverage` ### Parameters - **coverage_data** (dict) - Required - The coverage data obtained from `measure_suite_coverage` or `measure_test_coverage`. ### Response Example ```python [ CodeSegment(name='calculate_sum', file_path='mypackage/utils.py', line_start=5, line_end=15, missing_lines=[7, 8, 15]), CodeSegment(name='test_calculate_sum_basic', file_path='tests/test_utils.py', line_start=3, line_end=7, missing_lines=[6]) ] ``` ``` -------------------------------- ### Disable Flaky Test Detection Source: https://context7.com/plasma-umass/coverup/llms.txt Disable the default flaky test detection mechanism by using the --no-repeat-tests flag. This runs each generated test only once. ```bash # Disable flaky test detection (run tests only once) coverup --package-dir src/myapp --tests-dir tests --no-repeat-tests ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.