fixes test

This commit is contained in:
Mose Müller 2024-05-27 14:42:30 +02:00
parent d7e604992d
commit a0b7b92898

View File

@ -7,7 +7,6 @@ import pytest
from pydase import DataService from pydase import DataService
from pydase.data_service.data_service_observer import DataServiceObserver from pydase.data_service.data_service_observer import DataServiceObserver
from pydase.data_service.state_manager import StateManager from pydase.data_service.state_manager import StateManager
from pydase.data_service.task_manager import TaskDefinitionError
from pydase.utils.decorators import FunctionDefinitionError, frontend from pydase.utils.decorators import FunctionDefinitionError, frontend
from pytest import LogCaptureFixture from pytest import LogCaptureFixture
@ -118,14 +117,7 @@ def test_protected_and_private_attribute_warning(caplog: LogCaptureFixture) -> N
) not in caplog.text ) not in caplog.text
def test_exposing_methods() -> None: def test_exposing_methods(caplog: LogCaptureFixture) -> None:
class ClassWithTask(pydase.DataService):
async def some_task(self, sleep_time: int) -> None:
pass
with pytest.raises(TaskDefinitionError):
ClassWithTask()
with pytest.raises(FunctionDefinitionError): with pytest.raises(FunctionDefinitionError):
class ClassWithMethod(pydase.DataService): class ClassWithMethod(pydase.DataService):
@ -133,6 +125,18 @@ def test_exposing_methods() -> None:
def some_method(self, *args: Any) -> str: def some_method(self, *args: Any) -> str:
return "some method" 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: def test_dynamically_added_attribute(caplog: LogCaptureFixture) -> None:
class MyService(DataService): class MyService(DataService):