1

I'm writing a test software to control a few Agilent Instruments using PyVISA and VISA as well some Agilent IO libraries. I have create a "TesPlan" (testplan.py) that should "call" a few other Phyton test scripts (rf_test.py, rf_test1, rf_test2.py, etc)

At this point, I'm using a "Subprocess to open and execute all my test, however, I haven't fin the way to bring the results of each test into my main testplan.

Please see below my code:

  TEST-PLAN (testplan.py)  

  import visa 
  import time 
  import subprocess

  ##SubTest located at:
  test = "C:\\python_rf" 
  os.chdir(test) 
  import rf_test
  subprocess.Popen(['python', 'rf_test.py']) 
  print (status) 
  import rf_test1
  subprocess.Popen(['python', 'rf_test1.py']) 
  print (status)

  TEST SCRIPT (rf_test.py)
  ##Do some RF - GPS Testing 
  if all is OK 
  status = "PASS"

  TEST SCRIPT (rf_test1.py)
  ##Do some RF - GPS Testing 
  if all is OK 
  status = "PASS"

I need to bring the status from the Sub-Test into my main "Test-Plan" in order to evaluate the status and allow the unit to move to the next test.

1 Answer 1

1

Why are you using subprocesses at all? In general, subprocesses should not be necessary when you are calling scripts that are written in Python. You could instead make each test script be a function, let's saytest(), that returns the status. Then you can just import these modules and run rf_test.test(), rf_test1.test().

If for some reason using subprocesses is necessary, you could have your scripts either (1) print the status or (2) exit with a certain exit code, e.g. sys.exit(0) for success and sys.exit(1) for failure. You'd then parse the stdout captured by subprocess.run(['python', 'rf_test1.py']) in case (1) or get the exit codesubprocess.call(['python', 'rf_test1.py']) in case 2.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi @nnnmmm thanks for your comments, I was using a subprocess just because that's the way I found into this community. my sub-test are written in python. When you refer to create a function do you refer a " def rf(): " am I right ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.