-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrobot_interface.py
35 lines (27 loc) · 1.13 KB
/
robot_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from robot.version import get_version as robot_version
class RobotInterface(object):
def __init__(self):
major_version = int(robot_version().split('.')[0])
if major_version >= 5:
from .robot5_interface import (RobotResultInterface,
RobotRunningInterface)
elif major_version > 3:
from .robot4_interface import (RobotResultInterface,
RobotRunningInterface)
else:
from .robot3_interface import (RobotResultInterface,
RobotRunningInterface)
self.result = RobotResultInterface()
self.running = RobotRunningInterface()
def get_keywords_from(test):
if hasattr(test, 'body'):
return test.body.filter(keywords=True)
return test.keywords
def set_special_keyword(suite, keyword_type, keyword):
if hasattr(suite, keyword_type):
if keyword_type == 'setup':
suite.setup = keyword
elif keyword_type == 'teardown':
suite.teardown = keyword
else:
suite.keywords.append(keyword)