Tools
3 minute read
Go to Definition
If the cursor is placed on the name of a Python function in the editor press F12 to see the definition of the function. If the function is a .NET function a stub file, recognisable by the .pyi extension, is displayed.
A stub file contains the interface definition and documentation of the public (public) .NET members that can be accessed within the Python script. |
-
Assembly information and creation date of the stub file
-
Using the example of the class ScpiPowerSupplyModule, its members are illustrated:
-
Constructors
-
Properties
-
Methods
-
-
A member marked as favorite is listed at the top in autocomplete
You can jump back to the previous position using or the keyboard shortcut Ctrl+-. |
Error List
Errors, warnings and information messages related to the Python script are displayed in the Error List. Open the Python script module menu. By double-clicking on an error, you can jump directly to the corresponding line in the Python file.
in theToDo List
You can enter tasks in the Python script via comments which have to begin with a keyword for the respective task.
You find a list of keywords in main menu at .
Open the ToDo List of the Python script module menu.
in theOutput
The Output window displays debug information and the print
commands from the Python script.
Open the Python script module in the menu.
Call Stack
Open
in the menu of the Python script module .The Call Stack is a mechanism with which an interpreter (in this case the Python interpreter) can track its position in a script that calls several functions. The Call Stack contains information about the function and its original file that is currently being executed and the sub-functions that are called from the calling function.
The Call Stack is only active in debug mode . |
Code formatting
To format the Python code of a file automatically select or the keyboard shortcut Ctrl+Shift+F.
def Func(x,y, z =12) :
return x *Y*z#return
def Func(x, y, z=12):
return x * Y * z #return
The formatting tool can be configured with the pyproject.toml file, see YAPF documentation.
[tool.yapf]
based_on_style = 'pep8' (1)
column_limit = 240 (2)
1 | Use the style PEP 8 |
2 | Lines should not exceed 240 characters |
Git integration
If the versioning management software Git is installed, the following tools are available:
-
opens the Git-GUI, or Git Extensions if it is installed
-
displays the current branch and opens the Git GUI or the commit dialogue of Git Extensions
Unit tests
LisRT supports Unit testing with the help of Python - Unit Testing Framework. Click on the tool to open the Tests window.
-
Searching for unit tests
-
Executes all unit tests
-
Executes the selected unit tests
-
Cancels the test run
-
Filter for all, passed and failed tests
In this example, the Python method get_image_name(type_name) from the Python file visual.inspection.py is tested.
import unittest
from visual_inspection import *
class TestVisualInspection(unittest.TestCase): (1)
def test_get_image_name(self): (2)
type_name = 'test.png'
self.assertEqual('image_test.png', get_image_name(type_name)) (3)
1 | The name of a test case must begin with test |
2 | The name of a test must begin with test |
3 | The test ends with an assert function |
Feedback
Was this page helpful?
Glad to hear it! If you have any suggestions for improvement write to us.
Sorry to hear that. Please tell us what we can improve.