Skip to content
Merged
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
15 changes: 15 additions & 0 deletions atest/custon_deco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import functools


def custom_deco(arg1, arg2):
print(arg1, arg2)

def actual_decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
print("BEFORE")
value = func(*args, **kwargs)
print("AFTER")
return value
return wrapper
return actual_decorator
4 changes: 3 additions & 1 deletion atest/librarycomponents.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from custon_deco import custom_deco
from robotlibcore import keyword


Expand All @@ -13,8 +14,9 @@ class Names:
def method(self):
return 2

@custom_deco("foo", "bar")
@keyword('Custom name')
def _custom_name(self):
def _other_name_here(self):
return 3

def not_keyword(self):
Expand Down
2 changes: 1 addition & 1 deletion src/robotlibcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def __get_keyword_line(self, method):

def __get_keyword_path(self, method):
try:
return os.path.normpath(inspect.getfile(method))
return os.path.normpath(inspect.getfile(inspect.unwrap(method)))
except TypeError:
return None

Expand Down
4 changes: 2 additions & 2 deletions utest/test_get_keyword_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_location_in_main(lib, lib_path):

def test_location_in_class(lib, lib_path_components):
source = lib.get_keyword_source("method")
assert source == "%s:13" % lib_path_components
assert source == f"{lib_path_components}:14"


def test_decorator_wrapper(lib_types, lib_path_types):
Expand All @@ -55,7 +55,7 @@ def test_decorator_wrapper(lib_types, lib_path_types):

def test_location_in_class_custom_keyword_name(lib, lib_path_components):
source = lib.get_keyword_source("Custom name")
assert source == "%s:17" % lib_path_components
assert source == f"{lib_path_components}:19"


def test_no_line_number(lib, lib_path, when):
Expand Down
4 changes: 2 additions & 2 deletions utest/test_robotlibcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_dir():
"_DynamicCore__get_keyword_path",
"_HybridCore__get_members",
"_HybridCore__get_members_from_instance",
"_custom_name",
"_other_name_here",
"add_library_components",
"all_arguments",
"attributes",
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_getattr():
assert lib.instance_attribute == "not keyword"
assert lib.function() == 1
assert lib.method() == 2
assert lib._custom_name() == 3
assert lib._other_name_here() == 3
assert getattr(lib, "Custom name")() == 3
with pytest.raises(AttributeError) as exc_info:
lib.non_existing
Expand Down