Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Print results
Browse files Browse the repository at this point in the history
  • Loading branch information
tthijm committed Jun 10, 2024
1 parent e540817 commit ce136af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cov/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ def mark(self, branch_id: int) -> None:

def is_valid(self, branch_id: int) -> bool:
return 0 <= branch_id < self.amount_of_branches

def get_coverage(self) -> int:
return self.reached_branches.count(True) * 100 // self.amount_of_branches

def get_missing(self) -> str:
missing = [str(i) for i, v in enumerate(self.reached_branches) if v is False]
return " ".join(missing)
8 changes: 7 additions & 1 deletion cov/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Dict, Callable
from cov.benchmark import Benchmark
from tabulate import tabulate
import inspect

__all__ = ["test", "mark"]
Expand Down Expand Up @@ -33,4 +34,9 @@ def mark(branch_id: int) -> None:


def print_results() -> None:
print(results)
header = ["function name", "branch %", "missing branches"]
rows = [
(function_name, benchmark.get_coverage(), benchmark.get_missing()) for function_name, benchmark in results.items()
]

print(tabulate(rows, header))
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ test = [
"pytest-mock",
"typing-extensions>=4.3,<5",
"tzdata; sys_platform == 'win32'",
"tabulate",
]

[tool.setuptools]
Expand Down

0 comments on commit ce136af

Please sign in to comment.