forked from pexpect/pexpect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_winsize.py
executable file
·60 lines (49 loc) · 2.3 KB
/
test_winsize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/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 <[email protected]>
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.
'''
import pexpect
import unittest
from . import PexpectTestCase
import time
class TestCaseWinsize(PexpectTestCase.PexpectTestCase):
def test_initial_winsize(self):
""" Assert initial window dimension size (24, 80). """
p = pexpect.spawn('{self.PYTHONBIN} sigwinch_report.py'
.format(self=self), timeout=3)
# default size by PtyProcess class is 24 rows by 80 columns.
p.expect_exact('Initial Size: (24, 80)')
p.close()
def test_initial_winsize_by_dimension(self):
""" Assert user-parameter window dimension size is initial. """
p = pexpect.spawn('{self.PYTHONBIN} sigwinch_report.py'
.format(self=self), timeout=3,
dimensions=(40, 100))
p.expect_exact('Initial Size: (40, 100)')
p.close()
def test_setwinsize(self):
""" Ensure method .setwinsize() sends signal caught by child. """
p = pexpect.spawn('{self.PYTHONBIN} sigwinch_report.py'
.format(self=self), timeout=3)
# Note that we must await the installation of the child process'
# signal handler,
p.expect_exact('READY')
p.setwinsize(19, 84)
p.expect_exact('SIGWINCH: (19, 84)')
p.close()
if __name__ == '__main__':
unittest.main()
suite = unittest.makeSuite(TestCaseWinsize,'test')