From fcf98028fb120e97289923855466eac90cb63cd4 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 1 Nov 2026 13:10:42 +0100 Subject: [PATCH] test(security): let FakeGh hang a verb instead of subclassing it in the test CodeQL (py/call-to-non-callable, alerts 1073 and 1074 on PR #1326) could not see the __call__ of the HangingEdit class defined inside the test method and flagged both gh() calls in sync(). FakeGh now takes the verbs to hang as a parameter, so the test double stays one module-level class. Part of #1324 Co-Authored-By: Claude Opus 5.5 --- .../python/cli/contributing/security/test_issues.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/unit/python/cli/contributing/security/test_issues.py b/tests/unit/python/cli/contributing/security/test_issues.py index fd544ee64d..e2b7308a2a 100644 --- a/tests/unit/python/cli/contributing/security/test_issues.py +++ b/tests/unit/python/cli/contributing/security/test_issues.py @@ -24,11 +24,14 @@ TITLE = "🛡️ CVE-2026-109618 in docker.io/roundcube/roundcubemail:1.7.5-apac class FakeGh: - def __init__(self, open_issues): + def __init__(self, open_issues, hang=()): self.open_issues = open_issues + self.hang = [list(verb) for verb in hang] self.calls = [] def __call__(self, args): + if list(args[:2]) in self.hang: + raise subprocess.TimeoutExpired(["gh", *args], 120) self.calls.append(list(args)) if args[:2] == ["issue", "list"]: return json.dumps(self.open_issues) @@ -66,14 +69,8 @@ class TestSync(TestCase): self.assertEqual(gh.verbs(), []) def test_a_failed_issue_call_is_reported_and_the_others_still_run(self): - class HangingEdit(FakeGh): - def __call__(self, args): - if args[:2] == ["issue", "edit"]: - raise subprocess.TimeoutExpired(["gh", *args], 120) - return super().__call__(args) - other = {**ROW, "id": "CVE-2026-109619"} - gh = HangingEdit([{"number": 7, "title": TITLE}]) + gh = FakeGh([{"number": 7, "title": TITLE}], hang=[("issue", "edit")]) actions = issues_main.sync({"findings": [ROW, other], "errors": []}, "o/r", gh) self.assertTrue(actions[0].startswith(f"failed updated #7 {TITLE}")) self.assertEqual(gh.verbs(), [["issue", "create"]])