Hello community, here is the log from the commit of package python3-pexpect for openSUSE:Factory checked in at 2016-06-02 09:37:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-pexpect (Old) and /work/SRC/openSUSE:Factory/.python3-pexpect.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-pexpect" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-pexpect/python3-pexpect.changes 2015-10-22 12:58:59.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python3-pexpect.new/python3-pexpect.changes 2016-06-02 09:37:36.000000000 +0200 @@ -1,0 +2,13 @@ +Wed May 25 15:08:23 UTC 2016 - toddrme2...@gmail.com + +- update to version 4.1.0: + * No upstream changelog + +------------------------------------------------------------------- +Sun May 8 07:12:29 UTC 2016 - a...@gmx.de + +- specfile: + * updated source url to files.pythonhosted.org + + +------------------------------------------------------------------- Old: ---- pexpect-4.0.1.tar.gz New: ---- pexpect-4.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-pexpect.spec ++++++ --- /var/tmp/diff_new_pack.sQzjw9/_old 2016-06-02 09:37:37.000000000 +0200 +++ /var/tmp/diff_new_pack.sQzjw9/_new 2016-06-02 09:37:37.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package python3-pexpect # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,13 +17,13 @@ Name: python3-pexpect -Version: 4.0.1 +Version: 4.1.0 Release: 0 Summary: Pure Python Expect-like module License: ISC Group: Development/Libraries/Python Url: http://pexpect.readthedocs.org/en/latest/ -Source: https://pypi.python.org/packages/source/p/pexpect/pexpect-%{version}.tar.gz +Source: https://files.pythonhosted.org/packages/source/p/pexpect/pexpect-%{version}.tar.gz BuildRequires: python3-devel BuildRequires: python3-ptyprocess Requires: python3-ptyprocess ++++++ pexpect-4.0.1.tar.gz -> pexpect-4.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/.coveragerc new/pexpect-4.1.0/.coveragerc --- old/pexpect-4.0.1/.coveragerc 1970-01-01 01:00:00.000000000 +0100 +++ new/pexpect-4.1.0/.coveragerc 2015-12-08 19:43:59.000000000 +0100 @@ -0,0 +1,3 @@ +[run] +source = pexpect +parallel = True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/PKG-INFO new/pexpect-4.1.0/PKG-INFO --- old/pexpect-4.0.1/PKG-INFO 2015-10-06 16:36:49.000000000 +0200 +++ new/pexpect-4.1.0/PKG-INFO 2016-05-21 13:47:06.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pexpect -Version: 4.0.1 +Version: 4.1.0 Summary: Pexpect allows easy control of interactive console applications. Home-page: http://pexpect.readthedocs.org/ Author: Noah Spurrier; Thomas Kluyver; Jeff Quast @@ -32,7 +32,6 @@ Classifier: Operating System :: POSIX Classifier: Operating System :: MacOS :: MacOS X Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/README.rst new/pexpect-4.1.0/README.rst --- old/pexpect-4.0.1/README.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/pexpect-4.1.0/README.rst 2015-12-08 19:43:59.000000000 +0100 @@ -0,0 +1,55 @@ +.. image:: https://travis-ci.org/pexpect/pexpect.png?branch=master + :target: https://travis-ci.org/pexpect/pexpect + :align: right + :alt: Build status + +Pexpect is a Pure Python Expect-like module + +Pexpect makes Python a better tool for controlling other applications. + +Pexpect is a pure Python module for spawning child applications; controlling +them; and responding to expected patterns in their output. Pexpect works like +Don Libes' Expect. Pexpect allows your script to spawn a child application and +control it as if a human were typing commands. + +Pexpect can be used for automating interactive applications such as ssh, ftp, +passwd, telnet, etc. It can be used to a automate setup scripts for duplicating +software package installations on different servers. It can be used for +automated software testing. Pexpect is in the spirit of Don Libes' Expect, but +Pexpect is pure Python. + +The main features of Pexpect require the pty module in the Python standard +library, which is only available on Unix-like systems. Some features—waiting +for patterns from file descriptors or subprocesses—are also available on +Windows. + +If you want to work with the development version of the source code then please +read the DEVELOPERS.rst document in the root of the source code tree. + +Free, open source, and all that good stuff. + +You can install Pexpect using pip:: + + pip install pexpect + +`Docs on ReadTheDocs <http://pexpect.readthedocs.org/>`_ + +PEXPECT LICENSE:: + + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2013-2014, Pexpect development team + Copyright (c) 2012, Noah Spurrier <n...@noah.org> + + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +This license is approved by the OSI and FSF as GPL-compatible. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/doc/commonissues.rst new/pexpect-4.1.0/doc/commonissues.rst --- old/pexpect-4.0.1/doc/commonissues.rst 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/doc/commonissues.rst 2016-05-21 13:43:27.000000000 +0200 @@ -47,7 +47,7 @@ off:: child = pexpect.spawn ("ssh u...@example.com") - child.delaybeforesend = 0 + child.delaybeforesend = None Truncated output just before child exits ---------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/doc/conf.py new/pexpect-4.1.0/doc/conf.py --- old/pexpect-4.0.1/doc/conf.py 2015-10-06 16:31:40.000000000 +0200 +++ new/pexpect-4.1.0/doc/conf.py 2016-05-21 13:46:11.000000000 +0200 @@ -52,9 +52,9 @@ # built documents. # # The short X.Y version. -version = '4.0.1' +version = '4.1' # The full version, including alpha/beta/rc tags. -release = '4.0.1' +release = '4.1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/examples/passmass.py new/pexpect-4.1.0/examples/passmass.py --- old/pexpect-4.0.1/examples/passmass.py 2015-09-08 10:49:05.000000000 +0200 +++ new/pexpect-4.1.0/examples/passmass.py 2016-05-21 13:43:27.000000000 +0200 @@ -46,7 +46,7 @@ child = pexpect.spawn('ssh -l %s %s'%(user, host)) fout = file ("LOG.TXT","wb") - child.setlog (fout) + child.logfile = fout i = child.expect([pexpect.TIMEOUT, SSH_NEWKEY, '[Pp]assword: ']) if i == 0: # Timeout diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/pexpect/__init__.py new/pexpect-4.1.0/pexpect/__init__.py --- old/pexpect-4.0.1/pexpect/__init__.py 2015-10-06 16:31:30.000000000 +0200 +++ new/pexpect-4.1.0/pexpect/__init__.py 2016-05-21 13:45:40.000000000 +0200 @@ -75,7 +75,7 @@ from .pty_spawn import spawn, spawnu from .run import run, runu -__version__ = '4.0.1' +__version__ = '4.1.0' __revision__ = '' __all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'spawnu', 'run', 'runu', 'which', 'split_command_line', '__version__', '__revision__'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/pexpect/async.py new/pexpect-4.1.0/pexpect/async.py --- old/pexpect-4.0.1/pexpect/async.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/pexpect/async.py 2015-12-08 19:43:59.000000000 +0100 @@ -23,6 +23,7 @@ return expecter.timeout(e) class PatternWaiter(asyncio.Protocol): + transport = None def __init__(self, expecter): self.expecter = expecter self.fut = asyncio.Future() @@ -30,10 +31,15 @@ def found(self, result): if not self.fut.done(): self.fut.set_result(result) + self.transport.pause_reading() def error(self, exc): if not self.fut.done(): self.fut.set_exception(exc) + self.transport.pause_reading() + + def connection_made(self, transport): + self.transport = transport def data_received(self, data): spawn = self.expecter.spawn @@ -41,11 +47,11 @@ spawn._log(s, 'read') if self.fut.done(): - spawn.buffer += data + spawn.buffer += s return try: - index = self.expecter.new_data(data) + index = self.expecter.new_data(s) if index is not None: # Found a match self.found(index) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/pexpect/bashrc.sh new/pexpect-4.1.0/pexpect/bashrc.sh --- old/pexpect-4.0.1/pexpect/bashrc.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/pexpect-4.1.0/pexpect/bashrc.sh 2015-12-08 19:43:59.000000000 +0100 @@ -0,0 +1,5 @@ +source /etc/bash.bashrc +source ~/.bashrc + +# Reset PS1 so pexpect can find it +PS1="$" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/pexpect/expect.py new/pexpect-4.1.0/pexpect/expect.py --- old/pexpect-4.0.1/pexpect/expect.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/pexpect/expect.py 2016-05-21 13:43:27.000000000 +0200 @@ -44,6 +44,7 @@ spawn.match = None spawn.match_index = None msg = str(spawn) + msg += '\nsearcher: %s' % self.searcher if err is not None: msg = str(err) + '\n' + msg raise EOF(msg) @@ -63,6 +64,7 @@ spawn.match = None spawn.match_index = None msg = str(spawn) + msg += '\nsearcher: %s' % self.searcher if err is not None: msg = str(err) + '\n' + msg raise TIMEOUT(msg) @@ -95,7 +97,8 @@ return self.timeout() # Still have time left, so read more data incoming = spawn.read_nonblocking(spawn.maxread, timeout) - time.sleep(0.0001) + if self.spawn.delayafterread is not None: + time.sleep(self.spawn.delayafterread) if timeout is not None: timeout = end_time - time.time() except EOF as e: @@ -294,4 +297,4 @@ self.start = first_match self.match = the_match self.end = self.match.end() - return best_index \ No newline at end of file + return best_index diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/pexpect/pty_spawn.py new/pexpect-4.1.0/pexpect/pty_spawn.py --- old/pexpect-4.0.1/pexpect/pty_spawn.py 2015-10-06 15:22:14.000000000 +0200 +++ new/pexpect-4.1.0/pexpect/pty_spawn.py 2016-05-21 13:43:27.000000000 +0200 @@ -144,8 +144,7 @@ many users that I decided that the default pexpect behavior should be to sleep just before writing to the child application. 1/20th of a second (50 ms) seems to be enough to clear up the problem. You can set - delaybeforesend to 0 to return to the old behavior. Most Linux machines - don't like this to be below 0.03. I don't know why. + delaybeforesend to None to return to the old behavior. Note that spawn is clever about finding commands on your path. It uses the same logic that "which" uses to find executables. @@ -155,7 +154,12 @@ in self.exitstatus or self.signalstatus. If the child exited normally then exitstatus will store the exit return code and signalstatus will be None. If the child was terminated abnormally with a signal then - signalstatus will store the signal value and exitstatus will be None. + signalstatus will store the signal value and exitstatus will be None:: + + child = pexpect.spawn('some_command') + child.close() + print(child.exitstatus, child.signalstatus) + If you need more detail you can also read the self.status member which stores the status returned by os.waitpid. You can interpret this using os.WIFEXITED/os.WEXITSTATUS or os.WIFSIGNALED/os.TERMSIG. @@ -201,7 +205,6 @@ s.append(repr(self)) s.append('command: ' + str(self.command)) s.append('args: %r' % (self.args,)) - s.append('searcher: %r' % (self.searcher,)) s.append('buffer (last 100 chars): %r' % ( self.buffer[-100:] if self.buffer else self.buffer,)) s.append('before (last 100 chars): %r' % ( @@ -210,7 +213,8 @@ s.append('match: %r' % (self.match,)) s.append('match_index: ' + str(self.match_index)) s.append('exitstatus: ' + str(self.exitstatus)) - s.append('flag_eof: ' + str(self.flag_eof)) + if hasattr(self, 'ptyproc'): + s.append('flag_eof: ' + str(self.flag_eof)) s.append('pid: ' + str(self.pid)) s.append('child_fd: ' + str(self.child_fd)) s.append('closed: ' + str(self.closed)) @@ -285,8 +289,13 @@ if dimensions is not None: kwargs['dimensions'] = dimensions - self.ptyproc = ptyprocess.PtyProcess.spawn(self.args, env=self.env, - cwd=self.cwd, **kwargs) + if self.encoding is not None: + # Encode command line using the specified encoding + self.args = [a if isinstance(a, bytes) else a.encode(self.encoding) + for a in self.args] + + self.ptyproc = self._spawnpty(self.args, env=self.env, + cwd=self.cwd, **kwargs) self.pid = self.ptyproc.pid self.child_fd = self.ptyproc.fd @@ -295,6 +304,10 @@ 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 @@ -487,9 +500,9 @@ This value may be discovered using fpathconf(3):: - >>> from os import fpathconf - >>> print(fpathconf(0, 'PC_MAX_CANON')) - 256 + >>> from os import fpathconf + >>> print(fpathconf(0, 'PC_MAX_CANON')) + 256 On such a system, only 256 bytes may be received per line. Any subsequent bytes received will be discarded. BEL (``'\a'``) is then @@ -500,13 +513,14 @@ Canonical input processing may be disabled altogether by executing a shell, then stty(1), before executing the final program:: - >>> bash = pexpect.spawn('/bin/bash', echo=False) - >>> bash.sendline('stty -icanon') - >>> bash.sendline('base64') - >>> bash.sendline('x' * 5000) + >>> bash = pexpect.spawn('/bin/bash', echo=False) + >>> bash.sendline('stty -icanon') + >>> bash.sendline('base64') + >>> bash.sendline('x' * 5000) ''' - time.sleep(self.delaybeforesend) + if self.delaybeforesend is not None: + time.sleep(self.delaybeforesend) s = self._coerce_send_string(s) self._log(s, 'send') @@ -520,10 +534,8 @@ written. Only a limited number of bytes may be sent for each line in the default terminal mode, see docstring of :meth:`send`. ''' - - n = self.send(s) - n = n + self.send(self.linesep) - return n + s = self._coerce_send_string(s) + return self.send(s + self.linesep) def _log_control(self, s): """Write control characters to the appropriate log files""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/pexpect/pxssh.py new/pexpect-4.1.0/pexpect/pxssh.py --- old/pexpect-4.0.1/pexpect/pxssh.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/pexpect/pxssh.py 2015-12-08 19:43:59.000000000 +0100 @@ -46,7 +46,7 @@ Example that runs a few commands on a remote server and prints the result:: - import pxssh + from pexpect import pxssh import getpass try: s = pxssh.pxssh() @@ -70,7 +70,7 @@ Example showing how to specify SSH options:: - import pxssh + from pexpect import pxssh s = pxssh.pxssh(options={ "StrictHostKeyChecking": "no", "UserKnownHostsFile": "/dev/null"}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/pexpect/spawnbase.py new/pexpect-4.1.0/pexpect/spawnbase.py --- old/pexpect-4.0.1/pexpect/spawnbase.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/pexpect/spawnbase.py 2016-05-21 13:43:27.000000000 +0200 @@ -62,7 +62,7 @@ # Data before searchwindowsize point is preserved, but not searched. self.searchwindowsize = searchwindowsize # Delay used before sending data to child. Time in seconds. - # Most Linux machines don't like this to be below 0.03 (30 ms). + # Set this to None to skip the time.sleep() call completely. self.delaybeforesend = 0.05 # Used by close() to give kernel time to update process status. # Time in seconds. @@ -70,6 +70,12 @@ # Used by terminate() to give kernel time to update process status. # Time in seconds. self.delayafterterminate = 0.1 + # Delay in seconds to sleep after each call to read_nonblocking(). + # Set this to None to skip the time.sleep() call completely: that + # would restore the behavior from pexpect-2.0 (for performance + # reasons or because you don't want to release Python's global + # interpreter lock). + self.delayafterread = 0.0001 self.softspace = False self.name = '<' + repr(self) + '>' self.closed = True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/setup.cfg new/pexpect-4.1.0/setup.cfg --- old/pexpect-4.0.1/setup.cfg 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/setup.cfg 2016-05-21 13:43:33.000000000 +0200 @@ -1,2 +1,5 @@ [pytest] norecursedirs = .git + +[bdist_wheel] +universal=1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/setup.py new/pexpect-4.1.0/setup.py --- old/pexpect-4.0.1/setup.py 2015-10-06 16:29:56.000000000 +0200 +++ new/pexpect-4.1.0/setup.py 2016-05-21 13:44:41.000000000 +0200 @@ -2,6 +2,10 @@ from distutils.core import setup import os import re +import sys + +if any(a == 'bdist_wheel' for a in sys.argv): + from setuptools import setup with open(os.path.join(os.path.dirname(__file__), 'pexpect', '__init__.py'), 'r') as f: for line in f: @@ -33,6 +37,7 @@ setup (name='pexpect', version=version, packages=['pexpect'], + package_data={'pexpect': ['bashrc.sh']}, description='Pexpect allows easy control of interactive console applications.', long_description=long_description, author='Noah Spurrier; Thomas Kluyver; Jeff Quast', @@ -49,7 +54,6 @@ 'Operating System :: POSIX', 'Operating System :: MacOS :: MacOS X', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Topic :: Software Development', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/tests/log new/pexpect-4.1.0/tests/log --- old/pexpect-4.0.1/tests/log 2015-10-03 13:05:43.000000000 +0200 +++ new/pexpect-4.1.0/tests/log 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ -\,ESC -P,ESC -\,ESC -P,ESC -\,ESC -P,ESC -\,ESC -P,ESC -\,ESC -r,SEMICOLON diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/tests/test_async.py new/pexpect-4.1.0/tests/test_async.py --- old/pexpect-4.0.1/tests/test_async.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/tests/test_async.py 2015-12-08 19:43:59.000000000 +0100 @@ -43,9 +43,15 @@ coro = p.expect('Blah', async=True) with self.assertRaises(pexpect.EOF): run(coro) - + def test_expect_exact(self): p = pexpect.spawn('%s list100.py' % sys.executable) assert run(p.expect_exact(b'5', async=True)) == 0 assert run(p.expect_exact(['wpeok', b'11'], async=True)) == 1 assert run(p.expect_exact([b'foo', pexpect.EOF], async=True)) == 1 + + def test_async_utf8(self): + p = pexpect.spawn('%s list100.py' % sys.executable, encoding='utf8') + assert run(p.expect_exact(u'5', async=True)) == 0 + assert run(p.expect_exact([u'wpeok', u'11'], async=True)) == 1 + assert run(p.expect_exact([u'foo', pexpect.EOF], async=True)) == 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/tests/test_delay.py new/pexpect-4.1.0/tests/test_delay.py --- old/pexpect-4.0.1/tests/test_delay.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pexpect-4.1.0/tests/test_delay.py 2016-05-21 13:43:27.000000000 +0200 @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +from . import PexpectTestCase +import pexpect + + +class TestCaseDelay(PexpectTestCase.PexpectTestCase): + """ + Tests for various delay attributes. + """ + def test_delaybeforesend(self): + """ + Test various values for delaybeforesend. + """ + p = pexpect.spawn("cat") + + p.delaybeforesend = 1 + p.sendline("line 1") + p.expect("line 1") + + p.delaybeforesend = 0.0 + p.sendline("line 2") + p.expect("line 2") + + p.delaybeforesend = None + p.sendline("line 3") + p.expect("line 3") + + def test_delayafterread(self): + """ + Test various values for delayafterread. + """ + p = pexpect.spawn("cat") + + p.delayafterread = 1 + p.sendline("line 1") + p.expect("line 1") + + p.delayafterread = 0.0 + p.sendline("line 2") + p.expect("line 2") + + p.delayafterread = None + p.sendline("line 3") + p.expect("line 3") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/tests/test_expect.py new/pexpect-4.1.0/tests/test_expect.py --- old/pexpect-4.0.1/tests/test_expect.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/tests/test_expect.py 2016-05-21 13:43:27.000000000 +0200 @@ -433,7 +433,7 @@ self._before_after(p) def _ordering(self, p): - p.timeout = 5 + p.timeout = 20 p.expect(b'>>> ') p.sendline('list(range(4*3))') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/tests/test_maxcanon.py new/pexpect-4.1.0/tests/test_maxcanon.py --- old/pexpect-4.0.1/tests/test_maxcanon.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/tests/test_maxcanon.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,176 +0,0 @@ -""" Module for canonical-mode tests. """ -# std imports -import sys -import os - -# local -import pexpect -from . import PexpectTestCase - -# 3rd-party -import pytest - - -class TestCaseCanon(PexpectTestCase.PexpectTestCase): - """ - Test expected Canonical mode behavior (limited input line length). - - All systems use the value of MAX_CANON which can be found using - fpathconf(3) value PC_MAX_CANON -- with the exception of Linux - and FreeBSD. - - Linux, though defining a value of 255, actually honors the value - of 4096 from linux kernel include file tty.h definition - N_TTY_BUF_SIZE. - - Linux also does not honor IMAXBEL. termios(3) states, "Linux does not - implement this bit, and acts as if it is always set." Although these - tests ensure it is enabled, this is a non-op for Linux. - - FreeBSD supports neither, and instead uses a fraction (1/5) of the tty - speed which is always 9600. Therefor, the maximum limited input line - length is 9600 / 5 = 1920. - - These tests only ensure the correctness of the behavior described by - the sendline() docstring. pexpect is not particularly involved in - these scenarios, though if we wish to expose some kind of interface - to tty.setraw, for example, these tests may be re-purposed as such. - - Lastly, portions of these tests are skipped on Travis-CI. It produces - unexpected behavior not reproduced on Debian/GNU Linux. - """ - - def setUp(self): - super(TestCaseCanon, self).setUp() - - self.echo = False - if sys.platform.lower().startswith('linux'): - # linux is 4096, N_TTY_BUF_SIZE. - self.max_input = 4096 - self.echo = True - elif sys.platform.lower().startswith('sunos'): - # SunOS allows PC_MAX_CANON + 1; see - # https://bitbucket.org/illumos/illumos-gate/src/d07a59219ab7fd2a7f39eb47c46cf083c88e932f/usr/src/uts/common/io/ldterm.c?at=default#cl-1888 - self.max_input = os.fpathconf(0, 'PC_MAX_CANON') + 1 - elif sys.platform.lower().startswith('freebsd'): - # http://lists.freebsd.org/pipermail/freebsd-stable/2009-October/052318.html - self.max_input = 9600 / 5 - else: - # All others (probably) limit exactly at PC_MAX_CANON - self.max_input = os.fpathconf(0, 'PC_MAX_CANON') - - @pytest.mark.skipif( - sys.platform.lower().startswith('freebsd'), - reason='os.write to BLOCK indefinitely on FreeBSD in this case' - ) - def test_under_max_canon(self): - " BEL is not sent by terminal driver at maximum bytes - 1. " - # given, - child = pexpect.spawn('bash', echo=self.echo, timeout=5) - child.sendline('echo READY') - child.sendline('stty icanon imaxbel') - child.sendline('echo BEGIN; cat') - - # some systems BEL on (maximum - 1), not able to receive CR, - # even though all characters up until then were received, they - # simply cannot be transmitted, as CR is part of the transmission. - send_bytes = self.max_input - 1 - - # exercise, - child.sendline('_' * send_bytes) - - # fast forward beyond 'cat' command, as ^G can be found as part of - # set-xterm-title sequence of $PROMPT_COMMAND or $PS1. - child.expect_exact('BEGIN') - - # verify, all input is found in echo output, - child.expect_exact('_' * send_bytes) - - # BEL is not found, - with self.assertRaises(pexpect.TIMEOUT): - child.expect_exact('\a', timeout=1) - - # cleanup, - child.sendeof() # exit cat(1) - child.sendline('exit 0') # exit bash(1) - child.expect(pexpect.EOF) - assert not child.isalive() - assert child.exitstatus == 0 - - @pytest.mark.skipif( - sys.platform.lower().startswith('freebsd'), - reason='os.write to BLOCK indefinitely on FreeBSD in this case' - ) - def test_beyond_max_icanon(self): - " a single BEL is sent when maximum bytes is reached. " - # given, - child = pexpect.spawn('bash', echo=self.echo, timeout=5) - child.sendline('stty icanon imaxbel erase ^H') - child.sendline('cat') - send_bytes = self.max_input - - # exercise, - child.sendline('_' * send_bytes) - child.expect_exact('\a') - - # exercise, we must now backspace to send CR. - child.sendcontrol('h') - child.sendline() - - if os.environ.get('TRAVIS', None) == 'true': - # Travis-CI has intermittent behavior here, possibly - # because the master process is itself, a PTY? - return - - # verify the length of (maximum - 1) received by cat(1), - # which has written it back out, - child.expect_exact('_' * (send_bytes - 1)) - # and not a byte more. - with self.assertRaises(pexpect.TIMEOUT): - child.expect_exact('_', timeout=1) - - # cleanup, - child.sendeof() # exit cat(1) - child.sendline('exit 0') # exit bash(1) - child.expect_exact(pexpect.EOF) - assert not child.isalive() - assert child.exitstatus == 0 - - @pytest.mark.skipif( - sys.platform.lower().startswith('freebsd'), - reason='os.write to BLOCK indefinitely on FreeBSD in this case' - ) - def test_max_no_icanon(self): - " may exceed maximum input bytes if canonical mode is disabled. " - # given, - child = pexpect.spawn('bash', echo=self.echo, timeout=5) - child.sendline('stty -icanon imaxbel') - child.sendline('echo BEGIN; cat') - send_bytes = self.max_input + 11 - - # exercise, - child.sendline('_' * send_bytes) - - # fast forward beyond 'cat' command, as ^G can be found as part of - # set-xterm-title sequence of $PROMPT_COMMAND or $PS1. - child.expect_exact('BEGIN') - - if os.environ.get('TRAVIS', None) == 'true': - # Travis-CI has intermittent behavior here, possibly - # because the master process is itself, a PTY? - return - - # BEL is *not* found, - with self.assertRaises(pexpect.TIMEOUT): - child.expect_exact('\a', timeout=1) - - # verify, all input is found in output, - child.expect_exact('_' * send_bytes) - - # cleanup, - child.sendcontrol('c') # exit cat(1) (eof wont work in -icanon) - child.sendcontrol('c') - child.sendline('exit 0') # exit bash(1) - child.expect(pexpect.EOF) - assert not child.isalive() - assert child.exitstatus == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pexpect-4.0.1/tests/test_repr.py new/pexpect-4.1.0/tests/test_repr.py --- old/pexpect-4.0.1/tests/test_repr.py 2015-10-04 10:18:45.000000000 +0200 +++ new/pexpect-4.1.0/tests/test_repr.py 2016-05-21 13:43:27.000000000 +0200 @@ -24,3 +24,14 @@ # verify assert isinstance(value, str) + def test_str_before_spawn(self): + """ Exercise derived spawn.__str__() """ + # given, + child = pexpect.spawn(None, None) + child.read_nonblocking = lambda size, timeout: b'' + try: + child.expect('alpha', timeout=0.1) + except pexpect.TIMEOUT as e: + str(e) # Smoketest + else: + assert False, 'TIMEOUT exception expected. No exception raised.'