summaryrefslogtreecommitdiff
path: root/tests/test_popen_spawn.py
diff options
context:
space:
mode:
authorSteven Silvester <steven.silvester@ieee.org>2014-12-01 21:00:21 -0600
committerThomas Kluyver <takowl@gmail.com>2015-09-12 11:49:09 +0100
commit6407d849d4719c9aeda1eca011808044fb126764 (patch)
treebb035ce6955812cbb77f8003e5c0abd97b67ed58 /tests/test_popen_spawn.py
parentce7c7ed9ec8e5c9b985a51f911ba01bcb4c8d566 (diff)
downloadpexpect-git-6407d849d4719c9aeda1eca011808044fb126764.tar.gz
Add a sendeof method and tests
Diffstat (limited to 'tests/test_popen_spawn.py')
-rw-r--r--tests/test_popen_spawn.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/test_popen_spawn.py b/tests/test_popen_spawn.py
index ce6b33e..3431e49 100644
--- a/tests/test_popen_spawn.py
+++ b/tests/test_popen_spawn.py
@@ -29,9 +29,31 @@ from . import PexpectTestCase
class ExpectTestCase (PexpectTestCase.PexpectTestCase):
+ def test_expect_basic(self):
+ p = PopenSpawn('cat', timeout=5)
+ p.sendline(b'Hello')
+ p.sendline(b'there')
+ p.sendline(b'Mr. Python')
+ p.expect(b'Hello')
+ p.expect(b'there')
+ p.expect(b'Mr. Python')
+ p.sendeof()
+ p.expect(pexpect.EOF)
+
+ def test_expect_exact_basic(self):
+ p = PopenSpawn('cat', timeout=5)
+ p.sendline(b'Hello')
+ p.sendline(b'there')
+ p.sendline(b'Mr. Python')
+ p.expect_exact(b'Hello')
+ p.expect_exact(b'there')
+ p.expect_exact(b'Mr. Python')
+ p.sendeof()
+ p.expect_exact(pexpect.EOF)
+
def test_expect(self):
the_old_way = subprocess.Popen(args=['ls', '-l', '/bin'],
- stdout=subprocess.PIPE).communicate()[0].rstrip()
+ stdout=subprocess.PIPE).communicate()[0].rstrip()
p = PopenSpawn('ls -l /bin')
the_new_way = b''
while 1:
@@ -45,7 +67,7 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
def test_expect_exact(self):
the_old_way = subprocess.Popen(args=['ls', '-l', '/bin'],
- stdout=subprocess.PIPE).communicate()[0].rstrip()
+ stdout=subprocess.PIPE).communicate()[0].rstrip()
p = PopenSpawn('ls -l /bin')
the_new_way = b''
while 1:
@@ -64,7 +86,7 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
def test_expect_eof(self):
the_old_way = subprocess.Popen(args=['/bin/ls', '-l', '/bin'],
- stdout=subprocess.PIPE).communicate()[0].rstrip()
+ stdout=subprocess.PIPE).communicate()[0].rstrip()
p = PopenSpawn('/bin/ls -l /bin')
# This basically tells it to read everything. Same as pexpect.run()
# function.