moves inheritance warning into DataService, improves logic

This commit is contained in:
Mose Müller
2023-12-11 09:15:08 +01:00
parent a5fddf7e45
commit 0faf347376
3 changed files with 23 additions and 84 deletions

View File

@ -1,50 +0,0 @@
from pydase import DataService
from pytest import LogCaptureFixture
def test_class_attr_inheritance_warning(caplog: LogCaptureFixture) -> None:
class SubClass:
name = "Hello"
class ServiceClass(DataService):
attr_1 = SubClass()
ServiceClass()
assert (
"Class 'SubClass' does not inherit from DataService. This may lead to "
"unexpected behaviour!"
) in caplog.text
def test_instance_attr_inheritance_warning(caplog: LogCaptureFixture) -> None:
class SubClass:
name = "Hello"
class ServiceClass(DataService):
def __init__(self) -> None:
super().__init__()
self.attr_1 = SubClass()
ServiceClass()
assert (
"Class 'SubClass' does not inherit from DataService. This may lead to "
"unexpected behaviour!"
) in caplog.text
def test_protected_attribute_warning(caplog: LogCaptureFixture) -> None:
class SubClass:
name = "Hello"
class ServiceClass(DataService):
def __init__(self) -> None:
super().__init__()
self._subclass = SubClass
ServiceClass()
assert (
"Warning: Class SubClass does not inherit from DataService." not in caplog.text
)