Search code examples
pythonpython-3.xautomated-testsrobotframework

Is there a way to call Variables file multiple times with different arguments and have it override the previous call?


I want to create a Robot Keywords file for deploying different pods to Kubernetes. The configuration is chosen based on a parameter passed when calling the keyword from the test file. I created a custom python class to handle deployment. The class takes as parameters a config dictionary generated by "get_variables" function based on the parameters passed. I want to instantiate three objects of the class with 3 different config files generated by get_variables. However when I call get variables multiple times, the configuration is NOT overridden. It remains the same. Here's an example to further explain:

Variables  ../etc/get_test_config.py    ${arg1}     ${arg2}     ${arg3}
Library     k8s.K8s    ${config}    WITH NAME    frontend

Variables  ../etc/get_test_config.py    ${arg4}     ${arg5}     ${arg6}
Library     k8s.K8s    ${config}    WITH NAME    backend

Any solutions?


Solution

  • Yes.

    You can use the keyword Import Variables.