mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-19 16:10:01 +02:00
adds function testing if private attributes can take values that are not serializable
This commit is contained in:
parent
cddb83451a
commit
44d73c3b77
@ -1,9 +1,11 @@
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import pydase
|
||||
import pytest
|
||||
from pydase.data_service.data_service_observer import DataServiceObserver
|
||||
from pydase.data_service.state_manager import StateManager
|
||||
from pydase.utils.serialization.serializer import SerializationError
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
@ -122,3 +124,25 @@ def test_dynamic_list_entry_with_property(caplog: pytest.LogCaptureFixture) -> N
|
||||
|
||||
assert "'list_attr[0].name' changed to 'Hello'" not in caplog.text
|
||||
assert "'list_attr[0].name' changed to 'Hoooo'" in caplog.text
|
||||
|
||||
|
||||
def test_private_attribute_does_not_have_to_be_serializable() -> None:
|
||||
class MyService(pydase.DataService):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.publ_attr: Any = 1
|
||||
self.__priv_attr = (1,)
|
||||
|
||||
def change_publ_attr(self) -> None:
|
||||
self.publ_attr = (2,) # cannot be serialized
|
||||
|
||||
def change_priv_attr(self) -> None:
|
||||
self.__priv_attr = (2,)
|
||||
|
||||
service_instance = MyService()
|
||||
pydase.Server(service_instance)
|
||||
|
||||
with pytest.raises(SerializationError):
|
||||
service_instance.change_publ_attr()
|
||||
|
||||
service_instance.change_priv_attr()
|
||||
|
Loading…
x
Reference in New Issue
Block a user