-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pythonpath is not applied when loading libraries #2654
Comments
RIDE log belonging to the example:
|
I believe that this is a problem of the test case itself, because it should clearly indicate the Path to the Library/Resource. The test author should have written When you write Anyway, if we modify the code to include |
What I am looking for here is symmetry between a headless Robot run (e.g. in a ci/cd pipeline) and running from RIDE as an IDE. In the headless run, which is typically scripted, the pythonpath is set either before the call to Robot or as a command line argument. When running from RIDE, we try to stay away from the command line. Instead we have the preferences window. When entering an absolute path, I expect the behaviour to be identical compared to passing the pythonpath as command line argument to Robot. Currently this is the case when running the tests from RIDE, but not for editing. This could be the first thing to cover from this issue. I understand your concern about the relative path. This is different compared to headless runs and therefore maybe less straight forward. Because RIDE is a single application intended for interactive use it is common to switch between projects. From a user perspective it is inconvenient to modify the import settings after each switch. Even more so, when people work on different branches of the same project, it often goes unnoticed that the path is still wrong and they are testing against wrong dependencies. This is where the relative path becomes important and, if my memory doesn't fail me, this used to work in older versions of RIDE. When opening a project I typically select a folder, the test suite folder ( |
Now a bit more consise in reply to your question:
Plus that we will need to check whether |
This will be solved by local project configuration in the |
Maybe, but it will not solve all the relative vs absolute path issues. I would then commit the config file to source control, but I have no control over to which location people do the check out. |
I still think that the test should reference the library with relative
|
To be honest, that is actually what I do, but the import then still fails with the indirection to the tech libraries. |
But, it is OK to find documentation, when the user explicitly declares it in PYTHONPATH, and we may document that |
Regardless of personal preferences. I would expect that RIDE uses the exact same settings during editing and the test run. If the test run passes, all should be well and the libraries must be reachable during editing as well. |
Is e.g. no runtime changes or dependencies on RIDE installation etc.? |
I need to confirm. There is some internal processing of the variable, it is re-written to the path of the current test suite directory. |
@JFoederer Please try v2.0.8dev26. Your example would not work fully, because the way tech_lib is referenced in domain_lib. It actually worked fine, in Linux. |
I tried on v2.0.8dev26 with the following results, results are identical on both Windows and Linux.
|
That is the best I can do. |
I appreciate the effort, so if this is the best, I'll happily take it. |
Consider attached small example of a test suite that references a Python Robot library, that in turn references a technical library. All in separate folders from a single root folder called Example.
When I open the test_suite folder in RIDE and try to run it, it fails at first. This is expected, because both the Robot library and the technical library are imported using a path starting in the Example folder:
domain_lib.MyRobotLib.py
andtech_lib.myTechLib
.[ ERROR ] Error in file 'C:\Users\johan.foederer\sandbox\Example\test_suite\A.robot' on line 2: Library 'domain_lib\MyRobotLib.py' does not exist.
This can be fixed by setting the Pythonpath in RIDE's settings:
Setting
..
in the Pythonpath suffices to run the test suite successful. Using a relative path is useful because it always works, even when switching between multiple projects that use the same basic structure. Absolute paths also work, though.The issue is that the Pythonpath is used only for running the test suite, not when loading libraries. This causes the libraries to turn up red and documentation and auto-completion to be unavailable. This is still the case after restarting RIDE.
A work around is to open a command prompt, create the Pythonpath env variable and then start RIDE from the prompt. This is however not a suitable solution for people that are not accustomed to using command line and are expected to just open the project using the desktop short cut.
Download the example: Example.zip
The text was updated successfully, but these errors were encountered: