From 265349a6d9356796f8cbecca023e1d0d794d7bf8 Mon Sep 17 00:00:00 2001 From: krstf1 <121450186+krstf1@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:08:14 +0200 Subject: [PATCH] Add files via upload --- lizard_ext/lizardnd.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lizard_ext/lizardnd.py b/lizard_ext/lizardnd.py index 4db4509f..8e2a0cda 100644 --- a/lizard_ext/lizardnd.py +++ b/lizard_ext/lizardnd.py @@ -97,16 +97,32 @@ def get_loop_status(self): return self.current_function.bracket_loop +branch_coverage = { + "has_func_branch": False, + "no_func_branch": False +} + +def print_coverage(): + has_func_hit = branch_coverage["has_func_branch"] + no_func_hit = branch_coverage["no_func_branch"] + print(f"Branch 'has_func_branch' was {'hit' if has_func_hit else 'not hit'}") + print(f"Branch 'no_func_branch' was {'hit' if no_func_hit else 'not hit'}") + def get_method(cls, name): - """ python3 doesn't need the __func__ to get the func of the - method. - """ + """ python3 doesn't need the __func__ to get the func of the method. """ method = getattr(cls, name) if hasattr(method, "__func__"): + branch_coverage["has_func_branch"] = True method = method.__func__ + else: + branch_coverage["no_func_branch"] = True return method + + + + def patch(frm, accept_class): for method in [k for k in frm.__dict__ if not k.startswith("_")]: setattr(accept_class, method, get_method(frm, method)) @@ -131,3 +147,5 @@ def _init_nesting_depth_data(self, *_): patch(NDFileInfoAddition, FileInfoBuilder) patch_append_method(_init_nesting_depth_data, FunctionInfo, "__init__") + +