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

Method _test_pipe

Lib/test/test_asyncio/test_windows_events.py:125–161  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

123 self.assertEqual(res, 'done')
124
125 async def _test_pipe(self):
126 ADDRESS = r'\\.\pipe\_test_pipe-%s' % os.getpid()
127
128 with self.assertRaises(FileNotFoundError):
129 await self.loop.create_pipe_connection(
130 asyncio.Protocol, ADDRESS)
131
132 [server] = await self.loop.start_serving_pipe(
133 UpperProto, ADDRESS)
134 self.assertIsInstance(server, windows_events.PipeServer)
135
136 clients = []
137 for i in range(5):
138 stream_reader = asyncio.StreamReader(loop=self.loop)
139 protocol = asyncio.StreamReaderProtocol(stream_reader,
140 loop=self.loop)
141 trans, proto = await self.loop.create_pipe_connection(
142 lambda: protocol, ADDRESS)
143 self.assertIsInstance(trans, asyncio.Transport)
144 self.assertEqual(protocol, proto)
145 clients.append((stream_reader, trans))
146
147 for i, (r, w) in enumerate(clients):
148 w.write('lower-{}\n'.format(i).encode())
149
150 for i, (r, w) in enumerate(clients):
151 response = await r.readline()
152 self.assertEqual(response, 'LOWER-{}\n'.format(i).encode())
153 w.close()
154
155 server.close()
156
157 with self.assertRaises(FileNotFoundError):
158 await self.loop.create_pipe_connection(
159 asyncio.Protocol, ADDRESS)
160
161 return 'done'
162
163 def test_connect_pipe_cancel(self):
164 exc = OSError()

Callers 1

test_pipeMethod · 0.95

Calls 12

enumerateFunction · 0.85
start_serving_pipeMethod · 0.80
assertIsInstanceMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45
appendMethod · 0.45
writeMethod · 0.45
encodeMethod · 0.45
formatMethod · 0.45
readlineMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected