Skip to content

Commit ff380c1

Browse files
authored
Updates robotlibcore to 1.0rc3 version. (#1003)
This fixes problem when calling keywords methods, which uses the @Keyword decorator to change the keyword name, from the library instance when extending library Fixes #1001
1 parent f2b33bc commit ff380c1

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/SeleniumLibrary/base/robotlibcore.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,27 @@ def decorator(func):
3737

3838
PY2 = sys.version_info < (3,)
3939

40-
__version__ = '1.0rc2'
40+
__version__ = '1.0rc3'
4141

4242

4343
class HybridCore(object):
4444

4545
def __init__(self, library_components):
4646
self.keywords = {}
47+
self.attributes = {}
4748
self.add_library_components(library_components)
4849
self.add_library_components([self])
4950

5051
def add_library_components(self, library_components):
5152
for component in library_components:
5253
for name, func in self._get_members(component):
5354
if callable(func) and hasattr(func, 'robot_name'):
55+
kw = getattr(component, name)
5456
kw_name = func.robot_name or name
55-
self.keywords[kw_name] = getattr(component, name)
57+
self.keywords[kw_name] = kw
58+
# Expose keywords as attributes both using original
59+
# method names as well as possible custom names.
60+
self.attributes[name] = self.attributes[kw_name] = kw
5661

5762
def _get_members(self, component):
5863
if inspect.ismodule(component):
@@ -64,18 +69,18 @@ def _get_members(self, component):
6469
raise TypeError('Libraries must be modules or new-style class '
6570
'instances, got old-style class {!r} instead.'
6671
.format(component.__class__.__name__))
67-
return self._get_members_from_instannce(component)
72+
return self._get_members_from_instance(component)
6873

69-
def _get_members_from_instannce(self, instance):
74+
def _get_members_from_instance(self, instance):
7075
# Avoid calling properties by getting members from class, not instance.
7176
cls = type(instance)
7277
for name in dir(instance):
7378
owner = cls if hasattr(cls, name) else instance
7479
yield name, getattr(owner, name)
7580

7681
def __getattr__(self, name):
77-
if name in self.keywords:
78-
return self.keywords[name]
82+
if name in self.attributes:
83+
return self.attributes[name]
7984
raise AttributeError('{!r} object has no attribute {!r}'
8085
.format(type(self).__name__, name))
8186

@@ -84,7 +89,7 @@ def __dir__(self):
8489
my_attrs = dir(type(self)) + list(self.__dict__)
8590
else:
8691
my_attrs = super().__dir__()
87-
return sorted(set(my_attrs + list(self.keywords)))
92+
return sorted(set(my_attrs) | set(self.attributes))
8893

8994
def get_keyword_names(self):
9095
return sorted(self.keywords)

0 commit comments

Comments
 (0)