def test_expect_eof (self):
the_old_way = subprocess.Popen(args=['/bin/ls', '-l', '/bin'],
stdout=subprocess.PIPE).communicate()[0].rstrip()
p = pexpect.spawn('/bin/ls -l /bin')
p.expect(pexpect.EOF) # This basically tells it to read everything. Same as pexpect.run() function.
the_new_way = p.before
the_new_way = the_new_way.replace(b'\r\n', b'\n'
).replace(b'\r', b'\n').replace(b'\n\n', b'\n').rstrip()
the_old_way = the_old_way.replace(b'\r\n', b'\n'
).replace(b'\r', b'\n').replace(b'\n\n', b'\n').rstrip()
assert the_old_way == the_new_way, hex_diff(the_old_way, the_new_way)
评论列表
文章目录