File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 40
40
41
41
::
42
42
43
- TODO
43
+ import ast
44
+ import sys
45
+
46
+ from robot.api import get_model
47
+
48
+
49
+ class TestNamePrinter(ast.NodeVisitor):
50
+
51
+ def visit_File(self, node):
52
+ print(f"File '{node.source}' has following tests:")
53
+ # Must call `generic_visit` to visit also child nodes.
54
+ self.generic_visit(node)
55
+
56
+ def visit_KeywordSection(self, node):
57
+ # Overriding a visitor method without calling `generic_visit`
58
+ # prevents child nodes being visited. In this case it means
59
+ # `visit_Name` is not called with nodes in the keyword section.
60
+ pass
61
+
62
+ def visit_Name(self, node):
63
+ print(f"- {node.name}")
64
+
65
+
66
+ model = get_model(sys.argv[1])
67
+ TestNamePrinter().visit(model)
68
+
69
+
70
+ TODO: Add example modifying model.
44
71
"""
45
72
46
73
from .builders import get_model , get_resource_model
You can’t perform that action at this time.
0 commit comments