summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Demeyer <jdemeyer@cage.ugent.be>2015-12-04 11:48:57 +0100
committerJeroen Demeyer <jdemeyer@cage.ugent.be>2015-12-04 11:48:57 +0100
commitc1fa69bc90eef9e680e5daac0ebd9d07b57817b5 (patch)
treed041ae259d18e52e506b3dc5467d6ee750a68399
parent8cf885aa6c41310d14dc70270c4ecdcfaa16e477 (diff)
downloadpexpect-c1fa69bc90eef9e680e5daac0ebd9d07b57817b5.tar.gz
Allow overriding the call to PtyProcess.spawn()
-rw-r--r--pexpect/pty_spawn.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py
index 299016c..bb0c099 100644
--- a/pexpect/pty_spawn.py
+++ b/pexpect/pty_spawn.py
@@ -290,8 +290,8 @@ class spawn(SpawnBase):
self.args = [a if isinstance(a, bytes) else a.encode(self.encoding)
for a in self.args]
- self.ptyproc = ptyprocess.PtyProcess.spawn(self.args, env=self.env,
- cwd=self.cwd, **kwargs)
+ self.ptyproc = self.spawnpty(self.args, env=self.env,
+ cwd=self.cwd, **kwargs)
self.pid = self.ptyproc.pid
self.child_fd = self.ptyproc.fd
@@ -300,6 +300,10 @@ class spawn(SpawnBase):
self.terminated = False
self.closed = False
+ def spawnpty(self, args, **kwargs):
+ '''Spawn a pty and return an instance of PtyProcess.'''
+ return ptyprocess.PtyProcess.spawn(args, **kwargs)
+
def close(self, force=True):
'''This closes the connection with the child application. Note that
calling close() more than once is valid. This emulates standard Python