ATEasy Python Driver

Solution Available
Roman V.
Yehud,

Apr 25, 2020
4 Posts

1  |  0  

Re: ATEasy Python Driver

Hi,

My team is waiting for new ATEasy Python Driver to integrate it in the project.

The plan is to use driver instead using STDIO Process.

BR
Roman Vinnik

DrATEasy (Ron Y.)
Mission Viejo, CA

Apr 28, 2020
367 Posts

0  |  0  

Re: ATEasy Python Driver

Hi,

Attached is a pre-release of Python driver/example.

This is a preliminary and we will add more features in the future (v11).

You will need to install Python 3.8.2 from https://www.python.org/downloads/.

If you need or have request for additional features, please open a support incident and paste your request there.

Ronnie


File Attachment:
ATEasyPython.zip

Roman V.
Yehud,

Apr 29, 2020
4 Posts

0  |  0  

Re: ATEasy Python Driver

Hi,
Thank you very much for this amazing driver.
Verified the examples and look very good.
One point, that I can to understand is how we can catch the exception:
! Raise Python Exception and catch in ATEasy
if PYTHON Run("raise Exception('Exception')")=-1
    TestStatus=PASS
else
    TestStatus=FAIL
endif
How it's work? I add some exception in example file, but it's not visible in ATEasy.

BR
Roman

Tero S.
Irvine, CA

Apr 30, 2020
16 Posts

0  |  0  

Re: ATEasy Python Driver

Hi Roman,

PYTHON Run("raise Exception('Exception')") doesn't run the example script. It just interpreters one line in Python. For example, the below would raise a differently named exception in Python:
raise Exception('TheNameOfMyRaisedException')

This returns -1 if an exception was raised (and it is):
PYTHON Run("raise Exception('Exception')")=-1

Hope that helps.

Regards,
Tero

Idan U.
Rishon-letzion,

May 3, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Hello Tero And Ron,
Thank you very much for this driver !

I have 2 question regarding the usage:
1. where do the print statements go ? where can i see them ?
2. how can i use the driver when creating an object in OO python  ?
for example,if i run 10 tests and all of them use  a PSU object for example how can i pass the object between the tests ?

Regards,
Idan

Roman V.
Yehud,

May 3, 2020
4 Posts

0  |  0  

Re: ATEasy Python Driver

Additional to Idan's question, how it possible to load python CLASS and not just Function from loaded module?

Idan U.
Rishon-letzion,

May 4, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Hello Tero And Ron,
Thank you very much for this driver !

I have 2 question regarding the usage:
1. where do the print statements go ? where can i see them ?
2. how can i use the driver when creating an object in OO python  ?
for example,if i run 10 tests and all of them use  a PSU object for example how can i pass the object between the tests ?

Regards,
Idan

Idan U.
Rishon-letzion,

May 4, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Hello Tero And Ron,
Thank you very much for this driver !

I have 2 question regarding the usage:
1. where do the print statements go ? where can i see them ?
2. how can i use the driver when creating an object in OO python  ?
for example,if i run 10 tests and all of them use  a PSU object for example how can i pass the object between the tests ?

Regards,
Idan

Idan U.
Rishon-letzion,

May 4, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Hello,

Sorry about the multiple replays, every time i hit refresh it answer the thread apparently


Any update ?
to summarize
1. where do the print statements go ? where can i see them ?
2. how can i use the driver when creating an object in OO python  ?
for example,if i run 10 tests and all of them use  a PSU object for example how can i pass the object between the tests ?
3.how it possible to load python CLASS and not just Function from loaded module?

BR,
Idan

Tero S.
Irvine, CA

May 5, 2020
16 Posts

0  |  0  

Re: ATEasy Python Driver

Hi Idan,

I am working on examples for your question 1-3. We'll post the updated driver example with respect to your needs as soon as possible.

Regards,
Tero

Idan U.
Rishon-letzion,

May 11, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Hey Tero,

Is there any news on this ?

Regards,
Idan

Tero S.
Irvine, CA

May 11, 2020
16 Posts

0  |  0  

Re: ATEasy Python Driver

Hi Idan,

Yes, the driver was updated with examples to match your questions. As soon as it's merged, we'll post it for you.  
  1) By default, the standard output stream in Windows. From Python, you can use file-like objects to redirect the stream as you wish, or like it was done in the new example, overriding the sys.stdout.write method.
  2) You can reference the corresponding Python objects and save their addresses to an ATEasy variable.
  3) You can call your class constructor, Python object, in a similar manner to a def

Regards,
Tero

Idan U.
Rishon-letzion,

May 12, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Great News !!!

Can you please attach the new driver or send me a link ?

Regards,
Idan

DrATEasy (Ron Y.)
Mission Viejo, CA

May 12, 2020
367 Posts

0  |  0  

Re: ATEasy Python Driver

Attached is update Driver and example with Class/Methods calling and standard output.

Ronnie


File Attachment:
Python.zip

Idan U.
Rishon-letzion,

May 13, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Hello Tero and Ron.

Thank you very much for this driver !
i have 2 question regarding the class usage.

1. hPyArgs=PYTHON Set Args Tuple({})
Im getting an error if im not passing a string("abc123") or a const to it , can i pass a variable ? Test.name for example ?

2. hPyReturn=PYTHON Get Object FromAttribute(hPyClassInstance, "class_variable")
can i access method variable the same way i access class variables ?

Thanks again for all your hard work !

Regards,
Idan

Tero S.
Irvine, CA

May 13, 2020
16 Posts

0  |  0  

Re: ATEasy Python Driver

Hi Idan,

1.
You can index the avArgv and assign a variable to avArgv. This is done on line 4 of Test 1.8 with the Python client socket handle in avArgv[0].

2.
Depends on what namespace the variable is in:
- if variable is defined outside of function you can access
- if variable is defined in function's local namespace, the variable reference is dumped after invoke
- unless you return it or change its scope

Useful Python docs:
"
...
The local namespace for a function is created when the function is called, and deleted when the function returns or raises an exception that is not handled within the function
...
"
[ Source: https://docs.python.org/3/tutorial/classes.html#python-scopes-and-namespaces ]

Regards,
Tero

Idan U.
Rishon-letzion,

May 18, 2020
17 Posts

0  |  0  

Re: ATEasy Python Driver

Hello Tero,

when using hPyModule=PYTHON Module Import("C:\\GitRepos\\radar_validation_tools-atspy\\System\\TestsAPI\\FunTestMatrixATEasyAPI.py")
hPyModule return 0, where can i see why it failed to import the file ?

when i run it with python im not getting any errors.
using "python C:\\GitRepos\\radar_validation_tools-atspy\\System\\TestsAPI\\FunTestMatrixATEasyAPI.py"  in cmd there are no errors.

Regards,
Tero

Tero S.
Irvine, CA

May 18, 2020
16 Posts

0  |  0  

Re: ATEasy Python Driver

Hi Idan,

Module import uses PyImport_ImportModule() of the Python API.
[API, PyImport_ImportModule:
https://docs.python.org/3/c-api/import.html?#c.PyImport_ImportModule
]

It's not equivalent to running the interpreter from shell. The interpreter prints out exception if you are in TTY, so typing:
python {absoluteFilePath}
in cmd. And if there's an error, Python interpreter responds:
python: can't open file 'fileName': [Errno 2] No such file or directory

By default, the driver is initialized in *isolated mode, which means that it relies on you to tell it what environment you want to run your scripts in. I think this may be the reason why your module import fails: the script path isn't in sys.path list. You can add the path to TestsAPI in the driver PythonProjectPath. [Isolated mode:
https://docs.python.org/3/using/cmdline.html#id2
]

*It will however append to system path either the execution directory of the script or path in PythonProjectPath

Regards,
Tero

Solution Available
DrATEasy (Ron Y.)
Mission Viejo, CA

May 19, 2020
367 Posts

1  |  0  

Re: ATEasy Python Driver

Updated program and .py with standard input example:

Regards,
Ronnie


File Attachment:
Python.zip



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]