MCPcopy Index your code
hub / github.com/python/cpython / test_poll2

Method test_poll2

Lib/test/test_poll.py:128–154  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

126 @requires_subprocess()
127 @requires_resource('walltime')
128 def test_poll2(self):
129 cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
130 proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
131 bufsize=0)
132 self.enterContext(proc)
133 p = proc.stdout
134 pollster = select.poll()
135 pollster.register( p, select.POLLIN )
136 for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10:
137 fdlist = pollster.poll(tout)
138 if (fdlist == []):
139 continue
140 fd, flags = fdlist[0]
141 if flags & select.POLLHUP:
142 line = p.readline()
143 if line != b"":
144 self.fail('error: pipe seems to be closed, but still returns data')
145 continue
146
147 elif flags & select.POLLIN:
148 line = p.readline()
149 if not line:
150 break
151 self.assertEqual(line, b'testing...\n')
152 continue
153 else:
154 self.fail('Unexpected return value from select.poll: %s' % fdlist)
155
156 def test_poll3(self):
157 # test int overflow

Callers

nothing calls this directly

Calls 6

enterContextMethod · 0.80
pollMethod · 0.45
registerMethod · 0.45
readlineMethod · 0.45
failMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected