Edit python functions – MTS Multipurpose Elite User Manual
Page 282
The above syntax is the function variable code to get the value of the array variable.
Non-array variables
To read a test variable that is not an array, enter the code as in the following example:
functionVariableX=TestVariableX
Order of subfunctions
If you have more than one function within the main function, the main function should appear first in the
code, for example:
def SquareAndSum(a,b):
return Sum(pow(a,2) + pow(b,2))
def Sum(a,b):
return a+b
Here the main function SquareAndSum uses a helper subfunction Sum. Only the first function shows in
the global function list.
Note:
Limit the use of subfunctions and enter one function so that it appears in the global list correctly.
Parentheses
Parentheses ( ) indicate you must add a parameter to the function.
To specify a variable, click Edit List and select one or more variables.
Square brackets
Square brackets [ ] indicate you can add an optional parameter to the function. The brackets must be
removed in any case or an error occurs.
For More Information
Concept
Task
(p. 282)
Create Variables Used in Python Function Example
(p. 283)
Edit Python Functions
To edit a python function:
1. Click Explorer panel > Test Definition node > Functions tab.
2. Select the function you want to edit and click Edit.
The Edit Function window is displayed.
3. Type your changes to the Python code.
The result of the code syntax validation appears in the bottom panel of the window.
4. When you have finished, click OK to return to the Functions window.
282 | MTS TestSuite
Working with Variables