From a0b7b92898fc682c46f4fb3cf1347fdc70ea142c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Mon, 27 May 2024 14:42:30 +0200 Subject: [PATCH] fixes test --- tests/data_service/test_data_service.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/data_service/test_data_service.py b/tests/data_service/test_data_service.py index 77fc65b..8bb1b02 100644 --- a/tests/data_service/test_data_service.py +++ b/tests/data_service/test_data_service.py @@ -7,7 +7,6 @@ import pytest from pydase import DataService from pydase.data_service.data_service_observer import DataServiceObserver from pydase.data_service.state_manager import StateManager -from pydase.data_service.task_manager import TaskDefinitionError from pydase.utils.decorators import FunctionDefinitionError, frontend from pytest import LogCaptureFixture @@ -118,14 +117,7 @@ def test_protected_and_private_attribute_warning(caplog: LogCaptureFixture) -> N ) not in caplog.text -def test_exposing_methods() -> None: - class ClassWithTask(pydase.DataService): - async def some_task(self, sleep_time: int) -> None: - pass - - with pytest.raises(TaskDefinitionError): - ClassWithTask() - +def test_exposing_methods(caplog: LogCaptureFixture) -> None: with pytest.raises(FunctionDefinitionError): class ClassWithMethod(pydase.DataService): @@ -133,6 +125,18 @@ def test_exposing_methods() -> None: def some_method(self, *args: Any) -> str: return "some method" + class ClassWithTask(pydase.DataService): + async def some_task(self, sleep_time: int) -> None: + pass + + ClassWithTask() + + assert ( + "Async function 'some_task' is defined with at least one argument. If you want " + "to use it as a task, remove the argument(s) from the function definition." + in caplog.text + ) + def test_dynamically_added_attribute(caplog: LogCaptureFixture) -> None: class MyService(DataService):