MCPcopy Create free account
hub / github.com/pexpect/pexpect / test_expect

Method test_expect

tests/test_popen_spawn.py:54–66  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

52 p.expect_exact(pexpect.EOF)
53
54 def test_expect(self):
55 the_old_way = subprocess.Popen(args=['ls', '-l', '/bin'],
56 stdout=subprocess.PIPE).communicate()[0].rstrip()
57 p = PopenSpawn('ls -l /bin')
58 the_new_way = b''
59 while 1:
60 i = p.expect([b'\n', pexpect.EOF])
61 the_new_way = the_new_way + p.before
62 if i == 1:
63 break
64 the_new_way += b'\n'
65 the_new_way = the_new_way.rstrip()
66 assert the_old_way == the_new_way, len(the_old_way) - len(the_new_way)
67
68 def test_expect_exact(self):
69 the_old_way = subprocess.Popen(args=['ls', '-l', '/bin'],

Callers

nothing calls this directly

Calls 2

PopenSpawnClass · 0.90
expectMethod · 0.80

Tested by

no test coverage detected