1
votes

I have an robot project with some custom python libraries. There are also some variables in .py file that need to be imported by robot resource files.

My directory tree looks something like this:

|-Libraries
  |-myLibrary.py
|-Resources
  |-myResource.resource
|-Tests
  |-myTest.robot
|-Variables
  |-__init__.py
  |-myVariables.py

Within my resource files I'm importing the variables files like this:

*** Settings ***
Variables    ../Variables/myVariables.py

Now I want to import from my python library the same variables like in my resource file. I tried importing it like this:

# myLibrary.py
import Variables.myVariables

But robot framework then threw this error: ModuleNotFoundError: No module named 'Variables'. Additionally the robot language server inside VS Code could not find any keywords defined in myLibrary.py.

Anyone got some suggestions?

1

1 Answers

0
votes

I would suggest using YAML file to store the variables and that will work fine both in robot and in python. The YAML structure is very easy to understand and use and even build a external file from python it self using the PyYAML lib