From 57c2327ae3d1322d1cacdf96320db97b338a2339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 23 Dec 2025 22:17:33 +0100 Subject: [PATCH] [tests/results] implement more specific '#auth' checks --- test/test_results.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/test_results.py b/test/test_results.py index 08656863..55b8844b 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -56,14 +56,14 @@ AUTH_REQUIRED = { "poipiku", } -AUTH_KEYS = ( +AUTH_KEYS = { "username", "cookies", "api-key", "client-id", "access-token", "refresh-token", -) +} class TestExtractorResults(unittest.TestCase): @@ -145,7 +145,7 @@ class TestExtractorResults(unittest.TestCase): for key in AUTH_KEYS: config.set((), key, None) - if auth and not any(extr.config(key) for key in AUTH_KEYS): + if auth and not self._has_auth(extr, auth): self._skipped.append((result["#url"], "no auth")) self.skipTest("no auth") @@ -271,6 +271,19 @@ class TestExtractorResults(unittest.TestCase): for kwdict in kwdicts: self._test_kwdict(kwdict, metadata) + def _has_auth(self, extr, auth): + if auth is True: + auth = AUTH_KEYS + + if isinstance(auth, str): + return extr.config(auth) + if isinstance(auth, set): + return any(self._has_auth(extr, a) for a in auth) + if isinstance(auth, (tuple, list)): + return all(self._has_auth(extr, k) for k in auth) + + self.fail(f"Invalid '#auth' value: {auth!r}") + def _test_kwdict(self, kwdict, tests, parent=None): for key, test in tests.items():