Skip to content

Commit 3d76331

Browse files
committed
test (diracx): generate-test-file warns about potentially unused methods
1 parent 8110a73 commit 3d76331

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/Integration/FutureClient/generate-test-file.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44
import importlib
55
from itertools import zip_longest
6+
import subprocess
67

78
BASE_EXPORTS = {"export_whoami", "export_refreshConfiguration", "export_ping", "export_echo"}
89

@@ -23,6 +24,8 @@ def main(system, component):
2324
importlib.import_module(f"DIRAC.{system}System.Service.{component}Handler"), f"{component}Handler"
2425
)
2526

27+
dirac_location = importlib.import_module("DIRAC").__path__[0]
28+
2629
print("from functools import partial")
2730
print()
2831
print("import pytest")
@@ -53,7 +56,15 @@ def main(system, component):
5356
else:
5457
default = f" = {parameter.default}"
5558
type_infos += [f"{parameter.name}{dtype}{default}"]
59+
60+
cmd_check_used = ["grep", "-R", rf"\.{method_name}(", dirac_location]
61+
62+
res = subprocess.run(cmd_check_used, capture_output=True)
63+
is_method_used = bool(res.stdout)
64+
5665
print(f"def test_{method_name}(monkeypatch):")
66+
if not is_method_used:
67+
print(f" # WARNING: possibly unused")
5768
print(f" # {client_name}().{method_name}({', '.join(type_infos)})")
5869
print(f" method = {client_name}().{method_name}")
5970
print(f" pytest.skip()")

0 commit comments

Comments
 (0)