Passing Data between TestStand and Python
- Updated2024-11-26
- 4 minute(s) read
Passing Data between TestStand and Python
Purpose
This example demonstrates how you can pass TestStand data types to Python code modules.
Example File
Location
<TestStand Public>Examples\Fundamentals\Python\Passing Data to Python\Passing Data to Python.seq
Highlighted Features
- Mapping of Python and TestStand types
Major API
None
Prerequisites
Complete the following steps to install the required software and configure TestStand.
- Install a supported version of the CPython interpreter and add it to your PATH variable.
- Install the following libraries for the version of Python you installed:
- Python for Win32 (pywin32) extensions
- NumPy module (required for the NumPy Array example)
- In the Python Adapter Configuration dialog box, update the Python version TestStand uses to execute Python code modules. Note To run the example for Enums, you must use Python 3.6 or higher.
How to Use This Example
Review the sequences and steps in this example. Select a subsequence in the Sequences pane to view steps in the subsequence.
Sequence Call step in the MainSequence sequence | Subsequence the step calls | Purpose | Details |
---|---|---|---|
Working with Number | Number | Demonstrates passing numbers (integers and real) between TestStand and the Python module. | The subsequence has four sections that demonstrate adding, subtracting, multiplying, and dividing two TestStand numbers in the Python module. The four sections, delineated by Label steps, use 64-bit signed integers, 64-bit unsigned integers, 64-bit double-precision floating-point number, and float and integer together respectively. An Additional Results step completes each section to provide a summary of the results. |
Working with Boolean | Boolean | Demonstrates passing Boolean data between TestStand and the Python module. | The subsequence demonstrates the inversion of the Boolean state of a TestStand variable in a Python module. An Additional Results step provides a summary of the results. |
Working with String | String | Demonstrates passing string data between TestStand and the Python module. | The subsequence demonstrates the concatenation of two TestStand strings in a Python module. An Additional Results step provides a summary of the results. |
Working with List | List | Demonstrates passing data between TestStand arrays and Python lists. | The subsequence demonstrates different operations, such as sorting and converting array data to string data, the Python module performs on TestStand array data. |
Working with Tuple | Tuple | Demonstrates passing data between TestStand containers and Python tuples. | The subsequence retrieves a single element from a TestStand container using a Python module, sets a Python attribute as a tuple using a TestStand container, and inserts a Python tuple attribute into a TestStand container. |
Working with PyObject | PyObject | Demonstrates passing data between TestStand object references and Python objects (PyObject). | The Setup step group contains the following steps:
The Main step group contains the following steps:
|
Working with Dispatch | Dispatch | Demonstrates passing TestStand objects and COM objects implementing IDispatch between TestStand and the Python module. | The Main step group contains the following Action steps:
|
Working with Enum | Enum | Demonstrates passing enumerations between TestStand and the Python module. | The Main step group contains the following Action steps:
|
Working with NumPy Array | NumPy Array | Demonstrates passing data between a TestStand array and a Python NumPy array. | The subsequence demonstrates passing TestStand arrays to a Python module and performing a sorting operation using NumPy arrays. |
Complete the following steps to run the example.
- Click Execute»Single Pass to run the sequence.
- When execution completes, review the report.