From 3d7633188a9a3f9e3a26672f086d597d9e3e0fb4 Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Wed, 29 Nov 2023 11:23:37 +0100 Subject: [PATCH] test (diracx): generate-test-file warns about potentially unused methods --- tests/Integration/FutureClient/generate-test-file.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Integration/FutureClient/generate-test-file.py b/tests/Integration/FutureClient/generate-test-file.py index 6ec2bf200f1..e9e888bc4ad 100755 --- a/tests/Integration/FutureClient/generate-test-file.py +++ b/tests/Integration/FutureClient/generate-test-file.py @@ -3,6 +3,7 @@ import inspect import importlib from itertools import zip_longest +import subprocess BASE_EXPORTS = {"export_whoami", "export_refreshConfiguration", "export_ping", "export_echo"} @@ -23,6 +24,8 @@ def main(system, component): importlib.import_module(f"DIRAC.{system}System.Service.{component}Handler"), f"{component}Handler" ) + dirac_location = importlib.import_module("DIRAC").__path__[0] + print("from functools import partial") print() print("import pytest") @@ -53,7 +56,15 @@ def main(system, component): else: default = f" = {parameter.default}" type_infos += [f"{parameter.name}{dtype}{default}"] + + cmd_check_used = ["grep", "-R", rf"\.{method_name}(", dirac_location] + + res = subprocess.run(cmd_check_used, capture_output=True) + is_method_used = bool(res.stdout) + print(f"def test_{method_name}(monkeypatch):") + if not is_method_used: + print(f" # WARNING: possibly unused") print(f" # {client_name}().{method_name}({', '.join(type_infos)})") print(f" method = {client_name}().{method_name}") print(f" pytest.skip()")