Hi All,
I had a couple of questions regarding the robot apis and parsing model. A while back, I had built a tool that 'checks' robot files and verifies they are following a certain standard, such as test name format, keyword name format, checking unused variables, etc...
I recently started to refactor the checking tool after coming across the robot APIs as I found a lot of the parsing tools I developed had functionality already done in robot APIs.
Currently, for test suites, I built a class to make it a bit more readable and easier for our users, example as follows:
def __init__(self, suite):
self.suite = TestData(source=suite)
self.tests = [
test.name for test in self.suite.testcase_table.tests]
self.force_tags = [tag for tag in self.suite.setting_table.force_tags]
self.suite_variables = [
var.name for var in self.suite.variable_table.variables]
self.keywords = [
keyword.name for keyword in self.suite.keywords]
The above works great for test suite files, but I am looking to add the following functionality:
- Get the full header, (i.e. *** Settings *** instead of just Settings), not sure if this is possible? I know based on the table I can use .header
- Get the test case source, example, if I have:
My_Test
Keyword arg
Another Keyword arg
Just return the test source:
Keyword arg
Another Keyword arg
- Get all Library and Resource imports, so at the top of the file I would get any resource or python library I have imported. I saw there is some 'imports' within the settings_table but it doesn't seem to work as I had expected.
- I built in functionality for unused variables, just curious if something like this exists? Same for duplicate tests/keywords.
Last question is in regards to ResourceFile(). I used a very similar class as above:
def __init__(self, resource):
self.resource = ResourceFile(source=resource)
self.keywords = [
keyword.name for keyword in self.resource.keyword_table.keywords]
name works, but keywords does not. I tried a few other methods for getting keyword names, such as resource.keywords (which based on dir(resource) seems like a valid option). I get the exact same problem when trying to get resource variables.
I appreciate the help. I've been going through the robot docs and such for some time but I feel that some areas are missing examples and functionality, a bit hard to read. I was also a bit confused on difference between using the different classes between api and parsing, many seem to achieve the same functionality.
Thank you.