37,720
社区成员
发帖
与我相关
我的任务
分享
def run_fail_test(test_list):
for testcase in test_list.split(","):
status,output = commands.getstatusoutput("/usr/bin/python "+testcase)
print outpout
def run_fail_test(test_list):
297 for testcase in test_list.split(","):
298 # os.system("/usr/bin/python "+testcase)
299 command = "/usr/bin/python "+testcase
300 print command
301 #args = shlex.split(command)
302 # print args
303 children = subprocess.Popen(["/usr/bin/python",testcase],stdout=subprocess.PIPE)
304 stdoutput = children.communicate
305 if "Fail" in stdout :
306 print "testcase have failed case,need to check!"
307 exit(1)
308 else :
309 print "run testcase pass"
310 return 0
311
这个函数的定义如上,但是,最后会失败,失败的信息如下:
m = child.expect([self.newkeyPrompt, self.psswdPrompt, pexpect.EOF])
File "/usr/lib/python2.4/site-packages/pexpect.py", line 1311, in expect
return self.expect_list(compiled_pattern_list, timeout, searchwindowsize)
File "/usr/lib/python2.4/site-packages/pexpect.py", line 1325, in expect_list
return self.expect_loop(searcher_re(pattern_list), timeout, searchwindowsize)
File "/usr/lib/python2.4/site-packages/pexpect.py", line 1378, in expect_loop
c = self.read_nonblocking (self.maxread, timeout)
File "/usr/lib/python2.4/site-packages/pexpect.py", line 841, in read_nonblocking
self.logfile_read.flush()
IOError: [Errno 32] Broken pipe
所以,我想知道问题出在哪里呢,如果我用os.system去执行,是没有错误的