Skip to content

Commit

Permalink
fix: get source file and lineno in RF 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xyb committed Jun 7, 2022
1 parent d3a4d3b commit fa12110
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion DebugLibrary/steplistener.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ def _start_keyword(self, name, attrs):
self.debug()


# Hack to find the current runner Step to get the source path and line number.
# This method relies on the internal implementation logic of RF and may need
# to be modified when there are major changes to RF.
def find_runner_step():
stack = inspect.stack()
for frame in stack:
if frame.function == 'run_steps':
if (frame.function == 'run_steps' # RobotFramework < 4.0
or frame.function == 'run'): # RobotFramework >= 4.0
arginfo = inspect.getargvalues(frame.frame)
context.current_runner = arginfo.locals.get('runner')
context.current_runner_step = arginfo.locals.get('step')
if context.current_runner_step:
break


def set_step_mode(on=True):
Expand Down

0 comments on commit fa12110

Please sign in to comment.