Search code examples
pythonride

Is there a way to convert Ride .Robot txt files to Python Robot.api Code?


I know RIDE runs the .robot files and converts the txt into the Python robot.api calls. I am trying to see how something in ride converts to how it is called in robot.api

Is there a way to see how Ride uses the Robot.Api calls when running a Test Suite in ride?

Example for clarification:

.Robot file in Ride:

*** Settings ***
Library           DateTime

*** Test Case ***
A_Test_Case
Should Be Equal    1    1

Is the same as:

Python Robot.api:

from robot.api import TestSuite

suite = TestSuite(name='Test_Suite')
suite.resource.imports.library('DateTime')
testcase = suite.tests.create('Test_Case')
testcase.keywords.create('Should Be Equal', args=[1, 1])

I need to know if there is a way to see how a .robot file converts to it's python counterpart.


Solution

  • Is there a way to see how Ride uses the Robot.Api calls when running a Test Suite in ride?

    It doesn't quite work the way you think. There is no point in time when robot converts the first block of code in your question into your second block of code.

    I need to know if there is a way to see how a .robot file converts to it's python counterpart.

    It's open-source, so you can just dig into the code and look around. The place to start would be in the src/robot/parsing module. Be aware that what you are looking for doesn't exist in the format you're probably wanting to see.

    Instead of converting the robot text into a python script, the robot.parsing.parser module tokenizes the data via the robot.parsing.lexer and then converts the data to various internal models. There is no intermediate step where it outputs python code.

    On github is an issue for the work that went into creating the new parser. From that issue you can see commits for the new lexer and all of the other parts of the parsing process as it evolved.