From 232c9ce35c29911e30883bf939ce7869798254ee Mon Sep 17 00:00:00 2001 From: Aayush Goel <81844215+Aayush-Goel-04@users.noreply.github.com> Date: Mon, 7 Aug 2023 22:43:25 +0530 Subject: [PATCH] Add test for script & output rendered --- scripts/show-unused-features.py | 6 ++++-- tests/test_scripts.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/show-unused-features.py b/scripts/show-unused-features.py index c3020d57..1a84f5bb 100644 --- a/scripts/show-unused-features.py +++ b/scripts/show-unused-features.py @@ -93,8 +93,10 @@ def highlight_unused_features(feature_map: Dict[Feature, int], rules_feature_set for feature, count in feature_map.items(): if feature in rules_feature_set: continue - unused_features.append((get_colored(str(count)), get_colored(str(feature)))) - unused_features = sorted(unused_features, key=lambda x: x[0]) + unused_features.append((count, get_colored(str(feature)))) + unused_features = [ + (get_colored(str(count)), feature) for count, feature in sorted(unused_features, key=lambda x: x[0]) + ] print("\n") print(tabulate.tabulate(unused_features, headers=["Count", "Feature"], tablefmt="plain")) print("\n") diff --git a/tests/test_scripts.py b/tests/test_scripts.py index 4baa96a9..7c91bc57 100644 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -45,6 +45,7 @@ def get_rule_path(): pytest.param("show-capabilities-by-function.py", [get_file_path()]), pytest.param("show-features.py", [get_file_path()]), pytest.param("show-features.py", ["-F", "0x407970", get_file_path()]), + pytest.param("show-unused-features.py", [get_file_path()]), pytest.param("capa_as_library.py", [get_file_path()]), ], )