From 00443c1c576bd4fc1f0933cb9bbd2526c36f118f Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:34:23 +0100 Subject: [PATCH] chore: give the touched tests their right types --- tests/test_audit_regressions.py | 11 +++++++---- tests/test_exporters.py | 9 +++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index eb222147f..00332c83b 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -7594,6 +7594,12 @@ class CommentsSayWhy(unittest.TestCase): self.assertEqual(found, []) +class _ResponseBody(io.BytesIO): + """A body with the headers attribute urlopen's response carries.""" + + headers: dict[str, str] = {} + + class ExternalDownloadsFollowTheRunPolicy(unittest.TestCase): """download_external lived outside packresolve and fetched under --offline, into the system /tmp, holding the whole body in memory.""" @@ -7601,11 +7607,8 @@ class ExternalDownloadsFollowTheRunPolicy(unittest.TestCase): ENTRY = {"name": "ext.bin", "source_url": "https://example.invalid/ext.bin", "sha1": hashlib.sha1(b"payload").hexdigest()} - class _Body(io.BytesIO): - headers: dict = {} - def _response(self, body: bytes): - stream = self._Body(body) + stream = _ResponseBody(body) response = mock.MagicMock() response.__enter__.return_value = stream response.__exit__.return_value = False diff --git a/tests/test_exporters.py b/tests/test_exporters.py index d69a37757..b61f7aa8d 100644 --- a/tests/test_exporters.py +++ b/tests/test_exporters.py @@ -1382,7 +1382,7 @@ class RecalboxExport(unittest.TestCase): if not original.is_file(): self.skipTest("no cached original for recalbox") - def zips(text: str) -> dict[tuple[str, str], str]: + def zips(text: str) -> dict[tuple[str | None, str | None], str]: return { (s.get("platform"), b.get("path")): ",".join(sorted( v.strip().lower() for v in b.get("md5", "").split(",") @@ -2518,7 +2518,7 @@ class UpstreamFidelity(unittest.TestCase): "no upstream cache, run scripts/export_native.py --all --fetch" ) - def _export(self, platform: str, truth: dict | None = None) -> dict[str, str]: + def _export(self, platform: str, truth: dict | None = None) -> tuple[dict, dict[str, str]]: cache = UPSTREAM_CACHE / platform if not cache.is_dir(): self.skipTest(f"no cached original for {platform}") @@ -2627,8 +2627,9 @@ class UpstreamFidelity(unittest.TestCase): if child.tag == f"{namespace}element": continue if child.tag == f"{namespace}attribute": - if child.get("use") == "required" and child.get("name"): - found.add(child.get("name")) + name = child.get("name") + if child.get("use") == "required" and name: + found.add(name) continue found |= own_attributes(child) return found