From 62d57c12a8c708d05d31a080a5e6fb743e0b8812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20V=2E=20Treider?= Date: Fri, 17 Feb 2023 17:07:53 +0100 Subject: [PATCH] move to test utils. remove debug code --- cognite/client/data_classes/_base.py | 3 --- tests/tests_unit/test_base.py | 13 +------------ tests/utils.py | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 15 deletions(-) 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("