NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling imported python modules directly from teststand

I have 2017 teststand software that calls a single python.py file (using the older installed python steps), creating class instances and then calling methods on those created instances. I am working on updating the sequence file to Teststand 2022, and also would like to update the python calls to use the built in Python adapter instead of the python step. It is much nicer to work with the built in Python adapter instead of having to open a popup window every time I need to modify a python step.

 

The issue I am finding is that the older python steps seem to be able to directly create an instance of an imported module from the python.py file, where the newer python adapter cannot.

 

For example, I have a an extremely simple test.py file:

from json import JSONEncoder

def add(a:int, b:int) -> int:
    return a + b

 

The older python step has the ability to create an instance of JSONEncoder:

MattyTE_2-1724424947346.png

 

The new python adapter cannot do this:

MattyTE_1-1724424228484.png

 

I have even tried something like:

from json import JSONEncoder as foo

JSONEncoder = foo

def add(a:int, b:int) -> int:
    return a + b

This simply adds "foo" as another option in the "old" python step dropdown, and nothing in the new python adapter.

 

Is there something I am missing that is making the old python step and the new python adapter behave differently here? I would like to update to the newest python adapter without rewriting the python code.

0 Kudos
Message 1 of 1
(265 Views)