mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
fix: dont log private and protected attribute changes
This commit is contained in:
parent
0694a3d1ee
commit
8ac2c39908
@ -30,7 +30,9 @@ class DataServiceObserver(PropertyObserver):
|
|||||||
)
|
)
|
||||||
|
|
||||||
cached_value = cached_value_dict.get("value")
|
cached_value = cached_value_dict.get("value")
|
||||||
if cached_value != dump(value)["value"]:
|
if cached_value != dump(value)["value"] and all(
|
||||||
|
part[0] != "_" for part in full_access_path.split(".")
|
||||||
|
):
|
||||||
logger.debug("'%s' changed to '%s'", full_access_path, value)
|
logger.debug("'%s' changed to '%s'", full_access_path, value)
|
||||||
|
|
||||||
self._update_cache_value(full_access_path, value, cached_value_dict)
|
self._update_cache_value(full_access_path, value, cached_value_dict)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pydase
|
import pydase
|
||||||
|
import pytest
|
||||||
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
|
||||||
|
|
||||||
@ -74,3 +75,22 @@ def test_dynamic_list_property_dependencies() -> None:
|
|||||||
"list_attr[0]._name": ["list_attr[0].name"],
|
"list_attr[0]._name": ["list_attr[0].name"],
|
||||||
"list_attr[1]._name": ["list_attr[1].name"],
|
"list_attr[1]._name": ["list_attr[1].name"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_protected_or_private_change_logs(caplog: pytest.LogCaptureFixture) -> None:
|
||||||
|
class OtherService(pydase.DataService):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self._name = "Hi"
|
||||||
|
|
||||||
|
class MyService(pydase.DataService):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.subclass = OtherService()
|
||||||
|
|
||||||
|
service = MyService()
|
||||||
|
state_manager = StateManager(service)
|
||||||
|
DataServiceObserver(state_manager)
|
||||||
|
|
||||||
|
service.subclass._name = "Hello"
|
||||||
|
assert "'subclass._name' changed to 'Hello'" not in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user