我是 python 新手,刚刚开始开发 linux 应用程序自动化。
我正在尝试的场景是
thread.py --- 将调用所有主要设备线程并从测试用例加载测试
admincase.py --- 保存我的案例测试..
我无法做的是我想在加载测试时将某些对象从 thread.py 传递给 admincase.py。我怎么做..
我试图传递的对象是(EppQueue)
thread.py 代码
import threading
import sys
import time
import logging
import os
import Queue
from EPP import EPP
import ldtp
import ldtputils
from functions import functions
from admincases import admincases
import unittest
#logging.basicConfig(level=logging.DEBUG,
# format='(%(threadName)-10s) %(message)s',
# )
class inittest(unittest.TestCase):
global fun
global EppQueue
global window_name
def cleanup(epp_port):
if os.path.exists(epp_port):
os.unlink(epp_port)
def start_threads(EppQueue,server_ip,epp_port):
epp = EPP
EPP1 = threading.Thread(name='EPP', target=epp, args=(server_ip,54321,epp_port,EppQueue,))
EPP1.setDaemon(True)
EPP1.start()
return epp
fun = functions()
EppQueue = Queue.Queue(1)
server_ip ='192.168.10.125'
epp_port='/dev/ttyS17'
print "Starting"
cleanup(epp_port)
print "Clean up Over"
epp = start_threads(EppQueue,server_ip,epp_port)
raw_input("###### Please Start the main appilcation in the ATM and hit a KEY to continue ############")
check = 0
while check == 0:
window_name = fun.start_up_verify('atm_main_app')
if any(window_name):
check = 1
else:
check = 0
if not any(window_name):
print "Please start the application and run the test"
sys.exit(0)
else:
print window_name
print "SYSTEM IS READY TO PERFORM TEST"
raw_input("###### HIT ANY KEY TO START UNIT TEST ############")
raw_input("kkk")
test = unittest.defaultTestLoader.loadTestsFromName("admincases")
unittest.TextTestRunner(verbosity=2).run(test)
raw_input("keyy")
print "final"
admincase.py 代码
import unittest
from functions import functions
import time
import Queue
class admincases(unittest.TestCase):
global fun
global EppQueue
global window_name
def test_case_1(self):
print "test case 1"
window_name = 'frmatm_main_app'
fun.send_queue(self.EppQueue,"send_keys,&&&&&")
fun.verify_screen(window_name,"ico0")
fun.send_queue(self.EppQueue,"send_keys,C")
fun.verify_screen(window_name,"ManagementFunctions")
fun.send_queue(self.EppQueue,"send_keys,001234")
fun.verify_screen(window_name,"MainMenu")
fun.send_queue(self.EppQueue,"send_keys,1")
fun.verify_screen(window_name,"Diagnostics")
fun.send_queue(self.EppQueue,"send_keys,1")
fun.verify_screen(window_name,"TerminalStatus")
fun.send_queue(self.EppQueue,"send_keys,2")
time.sleep(10)
fun.send_queue(self.EppQueue,"send_keys,####****")
fun = functions()
#EppQueue = Queue.Queue(1)
在这方面需要一些帮助...