OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 ''' |
| 3 PEXPECT LICENSE |
| 4 |
| 5 This license is approved by the OSI and FSF as GPL-compatible. |
| 6 http://opensource.org/licenses/isc-license.txt |
| 7 |
| 8 Copyright (c) 2012, Noah Spurrier <noah@noah.org> |
| 9 PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY |
| 10 PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE |
| 11 COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. |
| 12 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 13 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 14 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 15 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 |
| 20 ''' |
| 21 import pexpect |
| 22 import unittest |
| 23 from . import PexpectTestCase |
| 24 import time |
| 25 |
| 26 class TestCaseWinsize(PexpectTestCase.PexpectTestCase): |
| 27 |
| 28 def test_initial_winsize(self): |
| 29 """ Assert initial window dimension size (24, 80). """ |
| 30 p = pexpect.spawn('{self.PYTHONBIN} sigwinch_report.py' |
| 31 .format(self=self), timeout=3) |
| 32 # default size by PtyProcess class is 24 rows by 80 columns. |
| 33 p.expect_exact('Initial Size: (24, 80)') |
| 34 p.close() |
| 35 |
| 36 def test_initial_winsize_by_dimension(self): |
| 37 """ Assert user-parameter window dimension size is initial. """ |
| 38 p = pexpect.spawn('{self.PYTHONBIN} sigwinch_report.py' |
| 39 .format(self=self), timeout=3, |
| 40 dimensions=(40, 100)) |
| 41 p.expect_exact('Initial Size: (40, 100)') |
| 42 p.close() |
| 43 |
| 44 def test_setwinsize(self): |
| 45 """ Ensure method .setwinsize() sends signal caught by child. """ |
| 46 p = pexpect.spawn('{self.PYTHONBIN} sigwinch_report.py' |
| 47 .format(self=self), timeout=3) |
| 48 # Note that we must await the installation of the child process' |
| 49 # signal handler, |
| 50 p.expect_exact('READY') |
| 51 p.setwinsize(19, 84) |
| 52 p.expect_exact('SIGWINCH: (19, 84)') |
| 53 p.close() |
| 54 |
| 55 if __name__ == '__main__': |
| 56 unittest.main() |
| 57 |
| 58 suite = unittest.makeSuite(TestCaseWinsize,'test') |
| 59 |
| 60 |
OLD | NEW |