diff --git a/cognite/client/data_classes/_base.py b/cognite/client/data_classes/_base.py index e0e48197ce..b9563868cc 100644 --- a/cognite/client/data_classes/_base.py +++ b/cognite/client/data_classes/_base.py @@ -259,15 +259,12 @@ def _load( return cls._load(json.loads(resource_list), cognite_client=cognite_client) elif isinstance(resource_list, list): - global ASDF - ASDF.append(resource_list) resources = [cls._RESOURCE._load(resource, cognite_client=cognite_client) for resource in resource_list] return cls(resources, cognite_client=cognite_client) raise TypeError(f"Resource list must be json str or list of dicts, not {type(resource_list)}") -ASDF = [] T_CogniteResourceList = TypeVar("T_CogniteResourceList", bound=CogniteResourceList) diff --git a/tests/tests_unit/test_base.py b/tests/tests_unit/test_base.py index 7889b10c21..ba2f28f748 100644 --- a/tests/tests_unit/test_base.py +++ b/tests/tests_unit/test_base.py @@ -24,6 +24,7 @@ CogniteUpdate, ) from cognite.client.exceptions import CogniteMissingClientError +from tests.utils import all_subclasses class MyResource(CogniteResource): @@ -118,18 +119,6 @@ def _load(cls, api_response): return cls(data["varA"]) -def all_subclasses(cls: type) -> list[type]: - return sorted( - filter( - # Get all subclasses, but not from any test directory: - lambda cls: str(cls).startswith(" list[type]: + """Returns a list (without duplicates) of all subclasses of a given class, sorted on import-path-name. + + Ignores classes not part of the main library, e.g. subclasses part of tests. + """ + return sorted( + filter( + lambda cls: str(cls).startswith("