The Squish IDE has some support for code analysis (showing syntax errors, unused variables, etc.) and code completion.
This articles describes the steps necessary to get code analysis and code completion to work in the Squish IDE for your own Python code to get rid of warnings in the Python script editor (such as “
Undefined variable: ...”).
Approach #1 - Add custom Python module folders to Python project¶
When Python’s import statement the folders containing shared scripts must be configured in either one of the following places:
Global Scripts view in the Squish IDE
PyDev’s Python interpreter library settings (atthis will not help Squish find anything and is only for the PyDev IDE
Interpreter - Python>
PyDev specific test suite settings for external libraries (at
PyDev Package Explorerview (to open this view go to
Other...), right click on
PyDev - PYTHONPATH, select tab
Step 1: Import error is being shown:
Step 2: Open
PyDev Package Explorer view (Window > Show View > Other… > PyDev > PyDev Package Explorer):
Step 3: Add to test suite’s
Step 4: Add external libraries and click
Force restore internal info:
Step 5: Import error still showing:
Step 6: Close editor and open file again - import error is not showing anymore:
Approach #2 - Add custom Python module folders to Global Scripts¶
Step 1: Open and select Global Scripts view (Window > Show View… > Squish Tests > Global Scripts).
Step 2: Add the folders with custom Python modules to the Global Script directories:
Handling “Undefined Variable” errors for Symbols provided by Squish Toolkit Wrappers¶
The symbols “visible” in the scripting language are very dynamic. Many of them are made visible only when an AUT has been hooked up by Squish. This is because Squish can work with a multitude of GUI toolkits, and for each different GUI toolkit different symbols are being exposed.
For example there is a
loadUrl() function when you have a Web application, but when you switch to the application context of a Qt application in the same test script, the
loadUrl() function will no longer be visible to the test script, until you switch back to the application context of the Web application.
The script editors in the Squish IDE however are not able to distinguish which type of application will be the “current”, therefore they cannot simple mark
loadUrl() as a function that is available all the time, because it isn’t available all the time. Instead, your script code determines when that function is available, by switching application contexts.
To avoid “
Undefined Variable” for symbols provided by Squish toolkit wrappers the following approaches can be used.
Approach #1 - Declaring symbols in an external file¶
Step #1 - Create external file with desired symbols
For this we will create a shared test suite resource, but using a Global Script or a file at an arbitrary path is possible, too.
Step #2 - Make symbol definitions available to PyDev
PyDev Package Explorer.
Right click on project, choose
PyDev - PYTHONPATH, select tab
Source Folders. (For paths outside of the test suite choose
Add source folderand expand the test suite entry and select
shared/scripts/qt_symbols.py(or the path to the external file).
Step #3 - Import all symbols from the file
Approach #2 - Declaring symbols in the same test script¶
Disabling PyDev’s Code Analysis¶
The Python code analysis can be configured at
The Python code completion can be configured at
Code Completion (ctx insensitive and common tokens).
Key combinations for Eclipse’s Content Assist and other functionalities can be configured at