mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-18 10:17:14 +02:00
feat: added property callbacks, added warnings
This commit is contained in:
34
tests/test_warnings.py
Normal file
34
tests/test_warnings.py
Normal file
@ -0,0 +1,34 @@
|
||||
from pytest import LogCaptureFixture
|
||||
|
||||
from pyDataInterface import DataService
|
||||
|
||||
from . import caplog # noqa
|
||||
|
||||
|
||||
def test_setattr_warnings(caplog: LogCaptureFixture) -> None: # noqa
|
||||
# def test_setattr_warnings(capsys: CaptureFixture) -> None:
|
||||
class SubClass:
|
||||
name = "Hello"
|
||||
|
||||
class ServiceClass(DataService):
|
||||
def __init__(self) -> None:
|
||||
self.attr_1 = SubClass()
|
||||
super().__init__()
|
||||
|
||||
ServiceClass()
|
||||
|
||||
assert "Warning: Class SubClass does not inherit from DataService." in caplog.text
|
||||
|
||||
|
||||
def test_private_attribute_warning(caplog: LogCaptureFixture) -> None: # noqa
|
||||
class ServiceClass(DataService):
|
||||
def __init__(self) -> None:
|
||||
self.__something = ""
|
||||
super().__init__()
|
||||
|
||||
ServiceClass()
|
||||
|
||||
assert (
|
||||
" Warning: You should not set private but rather protected attributes! Use "
|
||||
"_something instead of __something." in caplog.text
|
||||
)
|
Reference in New Issue
Block a user