diff options
author | Matthew Printz <matt.printz@rackspace.com> | 2014-02-06 12:25:43 -0600 |
---|---|---|
committer | Matthew Printz <matt.printz@rackspace.com> | 2014-02-06 12:25:43 -0600 |
commit | 954f2c743123f35c991318285ff7d63390e2bd62 (patch) | |
tree | ec5298ed3fec9c4c5a29c45946dd69d2afa12ce4 | |
parent | 4e995ddb77d7d1771a0bc79e0140b5bdff14058f (diff) | |
download | pexpect-954f2c743123f35c991318285ff7d63390e2bd62.tar.gz |
Adding test to for signal handling error
-rwxr-xr-x | tests/sigwinch_error.py | 32 | ||||
-rwxr-xr-x | tests/test_winsize.py | 15 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/sigwinch_error.py b/tests/sigwinch_error.py new file mode 100755 index 0000000..c2f5577 --- /dev/null +++ b/tests/sigwinch_error.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +''' +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier <noah@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. + +''' + +from __future__ import print_function + +import time + +def main(): + print("READY") + time.sleep(2) + print("END") + +if __name__ == '__main__': + main() diff --git a/tests/test_winsize.py b/tests/test_winsize.py index f029ad3..e532e51 100755 --- a/tests/test_winsize.py +++ b/tests/test_winsize.py @@ -22,6 +22,7 @@ import pexpect import unittest import PexpectTestCase import time +import signal class TestCaseWinsize(PexpectTestCase.PexpectTestCase): @@ -52,6 +53,20 @@ class TestCaseWinsize(PexpectTestCase.PexpectTestCase): p1.close() + def test_sinch_error (self): + ''' + This tests that the child process can set and get the windows size. + This makes use of an external script sigwinch_report.py. + ''' + def noop(x, y): + pass + signal.signal(signal.SIGALRM, noop) + + p1 = pexpect.spawn('%s sigwinch_error.py' % self.PYTHONBIN) + p1.expect('READY', timeout=10) + signal.alarm(1) + p1.expect('END', timeout=10) + # def test_parent_resize (self): # pid = os.getpid() # p1 = pexpect.spawn('%s sigwinch_report.py' % self.PYTHONBIN) |