2019-09-19 13:26:01 +00:00
|
|
|
import wexpect
|
|
|
|
import unittest
|
2020-02-22 22:03:28 +00:00
|
|
|
from tests import PexpectTestCase
|
2019-09-19 13:26:01 +00:00
|
|
|
|
|
|
|
class EchoTestCase(PexpectTestCase.PexpectTestCase):
|
|
|
|
def testPath(self):
|
|
|
|
# Path of cmd executable:
|
|
|
|
cmd_exe = 'cmd'
|
|
|
|
cmdPrompt = '>'
|
|
|
|
|
|
|
|
# Start the child process
|
|
|
|
p = wexpect.spawn(cmd_exe)
|
|
|
|
|
|
|
|
# Wait for prompt
|
|
|
|
p.expect(cmdPrompt)
|
|
|
|
|
|
|
|
# Send a command
|
|
|
|
p.sendline('echo hello')
|
|
|
|
p.expect(cmdPrompt)
|
|
|
|
|
|
|
|
self.assertEqual('hello', p.before.splitlines()[1])
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
|
|
|
|
suite = unittest.makeSuite(EchoTestCase,'test')
|