From c1fa69bc90eef9e680e5daac0ebd9d07b57817b5 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Fri, 4 Dec 2015 11:48:57 +0100 Subject: Allow overriding the call to PtyProcess.spawn() --- pexpect/pty_spawn.py | 8 ++++++-- 1 file 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 -- cgit v1.2.1