From 351f0936d61933aa1de0ce7cd97fcb1259092e15 Mon Sep 17 00:00:00 2001 From: Episkey Date: Tue, 18 Aug 2026 03:17:04 -0700 Subject: [PATCH] fix(test): replace collections.Callable, removed in Python 3.10 test_client_try_import used `isinstance(x, collections.Callable)`. `collections.Callable` has been an alias for `collections.abc.Callable` since 3.3 and was removed in 3.10, so the test raises: AttributeError: module 'collections' has no attribute 'Callable' The suite therefore only passes on Python <= 3.9. .travis.yml tests 3.5/3.6/3.7, which is why this was never noticed -- and Travis has not run on this repo for a long time either. Uses the builtin `callable()` instead of `collections.abc.Callable`: same semantics (collections.abc.Callable.__subclasshook__ just checks for __call__), and it drops the now-unused `collections` import rather than keeping one around for a single predicate. Verified on Python 3.11.9: before 1 failed, 47 passed, 37 skipped after 48 passed, 37 skipped --- tests/test_unit/test_core/test_client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_unit/test_core/test_client.py b/tests/test_unit/test_core/test_client.py index f9c1c03c..5797f31a 100644 --- a/tests/test_unit/test_core/test_client.py +++ b/tests/test_unit/test_core/test_client.py @@ -3,7 +3,6 @@ import pytest import logging -import collections import requests_mock from ucloud.client import Client @@ -102,5 +101,5 @@ def test_client_try_import(client): continue client_factory = getattr(client, name) - if isinstance(client_factory, collections.Callable): + if callable(client_factory): print(client_factory())