Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/robotlibcore/core/hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def __get_members_from_instance(self, instance):
yield name, getattr(owner, name)

def __getattr__(self, name):
if name == "attributes":
return super().__getattribute__(name)
if name in self.attributes:
return self.attributes[name]
msg = "{!r} object has no attribute {!r}".format(type(self).__name__, name)
Expand Down
10 changes: 10 additions & 0 deletions utest/test_robotlibcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,13 @@ def test_library_cannot_be_class():
with pytest.raises(TypeError) as exc_info:
HybridCore([HybridLibrary])
assert str(exc_info.value) == "Libraries must be modules or instances, got class 'HybridLibrary' instead."

def test_get_library_attr():
class TestClass(HybridCore):
def __init__(self):
self.a = self.b *2
super().__init__()

with pytest.raises(AttributeError):
TestClass()