diff --git a/python/aistore/sdk/obj/object_client.py b/python/aistore/sdk/obj/object_client.py index aa3dc70b86..745d48f389 100644 --- a/python/aistore/sdk/obj/object_client.py +++ b/python/aistore/sdk/obj/object_client.py @@ -113,7 +113,7 @@ def get(self, stream: bool, offset: Optional[int] = None) -> requests.Response: resp.raise_for_status() return resp - except ErrObjNotFound as _: + except ErrObjNotFound: if self._uname: return self._retry_with_new_smap( HTTP_METHOD_GET, diff --git a/python/tests/integration/sdk/test_object_ops.py b/python/tests/integration/sdk/test_object_ops.py index 1916316607..034de49a9f 100644 --- a/python/tests/integration/sdk/test_object_ops.py +++ b/python/tests/integration/sdk/test_object_ops.py @@ -36,6 +36,14 @@ from tests.integration import CLUSTER_ENDPOINT, REMOTE_SET +def has_enough_targets(): + """Check if the cluster has at least two targets before running tests.""" + try: + return len(Client(CLUSTER_ENDPOINT).cluster().get_info().tmap) >= 2 + except Exception: + return False # Assume failure means insufficient targets or unreachable cluster (AuthN) + + # pylint: disable=unused-variable, too-many-public-methods class TestObjectOps(RemoteEnabledTest): def setUp(self) -> None: @@ -399,10 +407,7 @@ def test_get_object_from_url(self): fetched_content = fetched_obj.get_reader().read_all() self.assertEqual(content, fetched_content) - @unittest.skipIf( - len(Client(CLUSTER_ENDPOINT).cluster().get_info().tmap) < 2, - "Test requires more than one target", - ) + @unittest.skipIf(not has_enough_targets(), "Test requires more than one target") def test_get_object_direct(self): """ Test fetching objects directly from the target node.