Python Adapter

The Python Adapter provides advanced functionality for calling Python code modules from TestStand.

Before using the Python Adapter in TestStand, install the required version of the CPython interpreter.
Note   During installation of the CPython interpreter, you must enable the option for adding the Python path to the environment variables.

Install the following Python packages to enable specific workflows:

Package Version Workflow
Python for Win32 (pywin32) 228 Passing TestStand objects or ActiveX objects that implement IDispatch between TestStand and Python.
Numpy 1.19.1 Passing an array of numbers from TestStand to Python as a NumPy array.
debugpy Perform step into debugging operations on Python modules.
Jedi View additional elements used in Python code modules, including inner classes, function and attribute names defined in a base class, and imported classes, attributes, and functions.

You can use the Python Adapter to complete the following tasks:

  • Execute Python scripts (.py) on disk by:
    • Calling a function defined in a module.
    • Getting/Setting the attributes defined in a module.
    • Creating a class instance.
    • Calling a member function or static function defined in the class.
    • Getting/Setting member attributes or static attributes defined in the class.
  • Execute Python scripts in supported Python versions. Refer to the TestStand Readme for supported Python versions.
  • Execute Python scripts out-of-process in the CPython interpreter.
  • Convert data between Python and TestStand variables.
  • Store/reuse the Python object in a TestStand variable (Object Reference).

You can also use multiple Python interpreter sessions to perform the following tasks:

  • Execute Python scripts in parallel.
  • Use multiple Python versions, such as 3.6 and 3.8, simultaneously in TestStand.

When you specify a module for a step, the TestStand Sequence Editor displays the Python Module Tab. TestStand User Interfaces launch the Edit Python Call dialog box.

Use the Python Adapter Configuration Dialog Box to configure the Python version and Python virtual environment path to use with the Python Adapter.