-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The instrumented code for _commonprefix() function and a coverage tes…
…t for it
- Loading branch information
1 parent
ab9afba
commit bb1d1f2
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
from typing import Iterable, List, Tuple | ||
from prompt_toolkit.completion.base import branch_coverage,_commonprefix | ||
|
||
def print_coverage(): | ||
print("\nCoverage report:") | ||
hit_branches = sum(branch_coverage.values()) | ||
total_branches = len(branch_coverage) | ||
coverage_percentage = (hit_branches / total_branches) * 100 | ||
for branch, hit in branch_coverage.items(): | ||
print(f"{branch} was {'hit' if hit else 'not hit'}") | ||
print(f"Coverage: {hit_branches}/{total_branches} branches hit ({coverage_percentage:.2f}%)\n") | ||
|
||
|
||
# Tests | ||
test_cases: List[Tuple[List[str], str]] = [] | ||
|
||
for strings, description in test_cases: | ||
print(f"\nTesting case: {description} - Input: {strings}") | ||
result = _commonprefix(strings) | ||
print("Common prefix:", result) | ||
|
||
print_coverage() | ||
|