Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_devpoll.py @ 86127:a3d09c19bb93
merge with 3.3
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 06 Oct 2013 19:24:00 +0200 |
| parents | ef889c3d5dc6 |
| children |
| rev | line source |
|---|---|
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
1 # Test case for the select.devpoll() function |
|
15305
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
14247
diff
changeset
|
2 |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
3 # Initial tests are copied as is from "test_poll.py" |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
4 |
|
85420
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
5 import os |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
6 import random |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
7 import select |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
8 import sys |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
9 import unittest |
|
52389
d4e7470bd660
Merged revisions 70554,70588-70589,70598,70605,70611-70621,70623-70624,70626-70627 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
47201
diff
changeset
|
10 from test.support import TESTFN, run_unittest |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
11 |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
12 try: |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
13 select.devpoll |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
14 except AttributeError: |
|
80429
520adfab957e
Clean up the messages used by some tests.
Brett Cannon <brett@python.org>
parents:
73549
diff
changeset
|
15 raise unittest.SkipTest("select.devpoll not defined") |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
16 |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
17 |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
18 def find_ready_matching(ready, flag): |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
19 match = [] |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
20 for fd, mode in ready: |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
21 if mode & flag: |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
22 match.append(fd) |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
23 return match |
|
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
24 |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
25 class DevPollTests(unittest.TestCase): |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
26 |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
27 def test_devpoll1(self): |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
28 # Basic functional test of poll object |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
29 # Create a bunch of pipe and test that poll works with them. |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
30 |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
31 p = select.devpoll() |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
32 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
33 NUM_PIPES = 12 |
|
42205
9b72f0636986
Fix test_poll.py. By Christian Heimes.
Guido van Rossum <guido@python.org>
parents:
40644
diff
changeset
|
34 MSG = b" This is a test." |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
35 MSG_LEN = len(MSG) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
36 readers = [] |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
37 writers = [] |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
38 r2w = {} |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
39 w2r = {} |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
40 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
41 for i in range(NUM_PIPES): |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
42 rd, wr = os.pipe() |
|
45996
376b5cb8a014
Merged revisions 61687-61688,61696,61700,61704-61705,61707-61709,61711-61712,61714-61716,61718-61722 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45471
diff
changeset
|
43 p.register(rd) |
|
376b5cb8a014
Merged revisions 61687-61688,61696,61700,61704-61705,61707-61709,61711-61712,61714-61716,61718-61722 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45471
diff
changeset
|
44 p.modify(rd, select.POLLIN) |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
45 p.register(wr, select.POLLOUT) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
46 readers.append(rd) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
47 writers.append(wr) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
48 r2w[rd] = wr |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
49 w2r[wr] = rd |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
50 |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
51 bufs = [] |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
52 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
53 while writers: |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
54 ready = p.poll() |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
55 ready_writers = find_ready_matching(ready, select.POLLOUT) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
56 if not ready_writers: |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
57 self.fail("no pipes ready for writing") |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
58 wr = random.choice(ready_writers) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
59 os.write(wr, MSG) |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
60 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
61 ready = p.poll() |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
62 ready_readers = find_ready_matching(ready, select.POLLIN) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
63 if not ready_readers: |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
64 self.fail("no pipes ready for reading") |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
65 self.assertEqual([w2r[wr]], ready_readers) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
66 rd = ready_readers[0] |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
67 buf = os.read(rd, MSG_LEN) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
68 self.assertEqual(len(buf), MSG_LEN) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
69 bufs.append(buf) |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
70 os.close(r2w[rd]) ; os.close(rd) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
71 p.unregister(r2w[rd]) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
72 p.unregister(rd) |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
73 writers.remove(r2w[rd]) |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
74 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
75 self.assertEqual(bufs, [MSG] * NUM_PIPES) |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
76 |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
77 def test_timeout_overflow(self): |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
78 pollster = select.devpoll() |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
79 w, r = os.pipe() |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
80 pollster.register(w) |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
81 |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
82 pollster.poll(-1) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
83 self.assertRaises(OverflowError, pollster.poll, -2) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
84 self.assertRaises(OverflowError, pollster.poll, -1 << 31) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
85 self.assertRaises(OverflowError, pollster.poll, -1 << 64) |
|
14175
8d1a059ae99d
Test suite for poll() interface (SF patch #100852)
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
86 |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
87 pollster.poll(0) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
88 pollster.poll(1) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
89 pollster.poll(1 << 30) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
90 self.assertRaises(OverflowError, pollster.poll, 1 << 31) |
|
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
91 self.assertRaises(OverflowError, pollster.poll, 1 << 63) |
|
40644
1c26505c1de6
Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents:
40450
diff
changeset
|
92 self.assertRaises(OverflowError, pollster.poll, 1 << 64) |
|
35834
418a61ead11b
Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint
Neal Norwitz <nnorwitz@gmail.com>
parents:
31515
diff
changeset
|
93 |
|
85300
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
94 def test_close(self): |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
95 open_file = open(__file__, "rb") |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
96 self.addCleanup(open_file.close) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
97 fd = open_file.fileno() |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
98 devpoll = select.devpoll() |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
99 |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
100 # test fileno() method and closed attribute |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
101 self.assertIsInstance(devpoll.fileno(), int) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
102 self.assertFalse(devpoll.closed) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
103 |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
104 # test close() |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
105 devpoll.close() |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
106 self.assertTrue(devpoll.closed) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
107 self.assertRaises(ValueError, devpoll.fileno) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
108 |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
109 # close() can be called more than once |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
110 devpoll.close() |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
111 |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
112 # operations must fail with ValueError("I/O operation on closed ...") |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
113 self.assertRaises(ValueError, devpoll.modify, fd, select.POLLIN) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
114 self.assertRaises(ValueError, devpoll.poll) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
115 self.assertRaises(ValueError, devpoll.register, fd, fd, select.POLLIN) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
116 self.assertRaises(ValueError, devpoll.unregister, fd) |
|
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
117 |
|
85420
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
118 def test_fd_non_inheritable(self): |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
119 devpoll = select.devpoll() |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
120 self.addCleanup(devpoll.close) |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
121 self.assertEqual(os.get_inheritable(devpoll.fileno()), False) |
|
ef889c3d5dc6
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
Victor Stinner <victor.stinner@gmail.com>
parents:
85300
diff
changeset
|
122 |
|
85300
ccbe2132392b
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
Victor Stinner <victor.stinner@gmail.com>
parents:
81589
diff
changeset
|
123 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
124 def test_main(): |
|
73549
8f7ab4bf7ad9
Issue #6397: Support '/dev/poll' polling objects in select module, under Solaris & derivatives.
Jesus Cea <jcea@jcea.es>
parents:
52389
diff
changeset
|
125 run_unittest(DevPollTests) |
|
36121
686306a67e9b
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
35834
diff
changeset
|
126 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
127 if __name__ == '__main__': |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
36121
diff
changeset
|
128 test_main() |
