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

Method test_expect_exact

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

Source from the content-addressed store, hash-verified

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'],
70 stdout=subprocess.PIPE).communicate()[0].rstrip()
71 p = PopenSpawn('ls -l /bin')
72 the_new_way = b''
73 while 1:
74 i = p.expect_exact([b'\n', pexpect.EOF])
75 the_new_way = the_new_way + p.before
76 if i == 1:
77 break
78 the_new_way += b'\n'
79 the_new_way = the_new_way.rstrip()
80
81 assert the_old_way == the_new_way, len(the_old_way) - len(the_new_way)
82 p = PopenSpawn('echo hello.?world')
83 i = p.expect_exact(b'.?')
84 self.assertEqual(p.before, b'hello')
85 self.assertEqual(p.after, b'.?')
86
87 def test_expect_eof(self):
88 the_old_way = subprocess.Popen(args=['ls', '-l', '/bin'],

Callers

nothing calls this directly

Calls 2

PopenSpawnClass · 0.90
expect_exactMethod · 0.80

Tested by

no test coverage detected