'Run a command using pexpect.
The pexpect child is returned.'

def spawn(self, cmd, expect_timeout=10.0):

    pexpect = pytest.importorskip('pexpect', '3.0')
    if (hasattr(sys, 'pypy_version_info') and ('64' in platform.machine())):
        pytest.skip('pypy-64    bit    not    supported')
    if sys.platform.startswith('freebsd'):
        pytest.xfail('pexpect    does    not    work    reliably    on    freebsd')
    logfile = self.tmpdir.join('spawn.out').open('wb')
    child = pexpect.spawn(cmd, logfile=logfile)
    self.request.addfinalizer(logfile.close)
    child.timeout = expect_timeout
    return child
