From 194e01d0e98e4a90affea082e92b2f3cfe58cb19 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 12 Nov 2026 08:02:56 +0000 Subject: [PATCH] fix(tests): give the dict-based test fakes an __eq__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _HttpResponse in the funkwhale same-origin test and _RawGetHostvars in the email lookup test subclass dict and add their own attribute, so dict equality ignored that attribute (CodeQL py/missing-equals). Each now compares as the same type, the same dict content and the same extra attribute. 🎯 Fix: 92 % 💥 Break: 1 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 91 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 --- tests/unit/python/plugins/lookup/test_email.py | 7 +++++++ .../roles/web-app-funkwhale/files/same_origin/test_urls.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/tests/unit/python/plugins/lookup/test_email.py b/tests/unit/python/plugins/lookup/test_email.py index 9845c2998d..a1191449af 100644 --- a/tests/unit/python/plugins/lookup/test_email.py +++ b/tests/unit/python/plugins/lookup/test_email.py @@ -807,6 +807,13 @@ class _RawGetHostvars(dict): super().__init__(templated) self._raw = raw + def __eq__(self, other: object) -> bool: + return ( + isinstance(other, _RawGetHostvars) + and dict.__eq__(self, other) + and self._raw == other._raw + ) + def raw_get(self, host: str) -> dict: return self._raw[host] diff --git a/tests/unit/python/roles/web-app-funkwhale/files/same_origin/test_urls.py b/tests/unit/python/roles/web-app-funkwhale/files/same_origin/test_urls.py index 952293b096..7a5bfd4648 100644 --- a/tests/unit/python/roles/web-app-funkwhale/files/same_origin/test_urls.py +++ b/tests/unit/python/roles/web-app-funkwhale/files/same_origin/test_urls.py @@ -34,6 +34,13 @@ class _HttpResponse(dict): super().__init__() self.content_type = content_type + def __eq__(self, other: object) -> bool: + return ( + isinstance(other, _HttpResponse) + and dict.__eq__(self, other) + and self.content_type == other.content_type + ) + def funkwhale_get_file_path(audio_file) -> bytes: """