From e96e1b6d6c1986803f38d67da155a5ce90dd2690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 21 Jun 2024 20:13:34 +0200 Subject: [PATCH] Upgrading VMware an fixing up things --- server/src/tests/utils/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/tests/utils/__init__.py b/server/src/tests/utils/__init__.py index 071729907..6a3c4f3de 100644 --- a/server/src/tests/utils/__init__.py +++ b/server/src/tests/utils/__init__.py @@ -163,18 +163,20 @@ class MustBeOfType: def __repr__(self) -> str: return self.__str__() -def search_item_by_attr(lst: list[T], attribute: str, value: typing.Any) -> T: +def search_item_by_attr(lst: list[T], attribute: str, value: typing.Any, **kwargs: typing.Any) -> T: """ Returns an item from a list of items + kwargs are not used, just to let use it as partial on fixtures """ for item in lst: if getattr(item, attribute) == value: return item raise ValueError(f'Item with {attribute}=="{value}" not found in list {str(lst)[:100]}') -def filter_list_by_attr(lst: list[T], attribute: str, value: typing.Any) -> list[T]: +def filter_list_by_attr(lst: list[T], attribute: str, value: typing.Any, **kwargs: typing.Any) -> list[T]: """ Returns a list of items from a list of items + kwargs are not used, just to let use it as partial on fixtures """ return [item for item in lst if getattr(item, attribute) == value or value is None]