Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: third_party/pexpect/tests/depricated_test_filedescriptor.py

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/pexpect/tests/bambi.vt ('k') | third_party/pexpect/tests/echo_w_prompt.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 import PexpectTestCase
24 import os
25
26 class ExpectTestCase(PexpectTestCase.PexpectTestCase):
27 def setUp(self):
28 print(self.id())
29 PexpectTestCase.PexpectTestCase.setUp(self)
30
31 def test_fd (self):
32 fd = os.open ('TESTDATA.txt', os.O_RDONLY)
33 s = pexpect.spawn (fd)
34 s.expect ('This is the end of test data:')
35 s.expect (pexpect.EOF)
36 assert s.before == ' END\n'
37
38 def test_maxread (self):
39 fd = os.open ('TESTDATA.txt', os.O_RDONLY)
40 s = pexpect.spawn (fd)
41 s.maxread = 100
42 s.expect('2')
43 s.expect ('This is the end of test data:')
44 s.expect (pexpect.EOF)
45 assert s.before == ' END\n'
46
47 def test_fd_isalive (self):
48 fd = os.open ('TESTDATA.txt', os.O_RDONLY)
49 s = pexpect.spawn (fd)
50 assert s.isalive()
51 os.close (fd)
52 assert not s.isalive()
53
54 def test_fd_isatty (self):
55 fd = os.open ('TESTDATA.txt', os.O_RDONLY)
56 s = pexpect.spawn (fd)
57 assert not s.isatty()
58 os.close(fd)
59
60 ### def test_close_does_not_close_fd (self):
61 ### '''Calling close() on a pexpect.spawn object should not
62 ### close the underlying file descriptor.
63 ### '''
64 ### fd = os.open ('TESTDATA.txt', os.O_RDONLY)
65 ### s = pexpect.spawn (fd)
66 ### try:
67 ### s.close()
68 ### self.fail('Expected an Exception.')
69 ### except pexpect.ExceptionPexpect, e:
70 ### pass
71
72 if __name__ == '__main__':
73 unittest.main()
74
75 suite = unittest.makeSuite(ExpectTestCase, 'test')
76
77 #fout = open('delete_me_1','wb')
78 #fout.write(the_old_way)
79 #fout.close
80 #fout = open('delete_me_2', 'wb')
81 #fout.write(the_new_way)
82 #fout.close
OLDNEW
« no previous file with comments | « third_party/pexpect/tests/bambi.vt ('k') | third_party/pexpect/tests/echo_w_prompt.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698