summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_windows_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-25 14:32:06 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-25 14:32:06 (GMT)
commit8dffc456d74a3a4395ac7a8f3957ff74f7f66753 (patch)
treee6a0b0a8ceaea275bfba7276698842f3a0ab5d79 /Lib/test/test_asyncio/test_windows_events.py
parent75a5ec88ff41ad7d3909e54ce517754298b31404 (diff)
downloadcpython-8dffc456d74a3a4395ac7a8f3957ff74f7f66753.zip
cpython-8dffc456d74a3a4395ac7a8f3957ff74f7f66753.tar.gz
cpython-8dffc456d74a3a4395ac7a8f3957ff74f7f66753.tar.bz2
Update asyncio from the Tulip project
Major changes: - StreamReader.readexactly() now raises an IncompleteReadError if the end of stream is reached before we received enough bytes, instead of returning less bytes than requested. - Unit tests use the main asyncio module instead of submodules like events - _UnixWritePipeTransport now also supports character devices, as _UnixReadPipeTransport. Patch written by Jonathan Slenders. - Export more symbols: BaseEventLoop, BaseProactorEventLoop, BaseSelectorEventLoop, Queue and Queue sublasses, Empty, Full
Diffstat (limited to 'Lib/test/test_asyncio/test_windows_events.py')
-rw-r--r--Lib/test/test_asyncio/test_windows_events.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index 17c204a..3c271eb 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -8,17 +8,12 @@ if sys.platform != 'win32':
import _winapi
import asyncio
-
-from asyncio import windows_events
-from asyncio import futures
-from asyncio import protocols
-from asyncio import streams
-from asyncio import transports
from asyncio import test_utils
from asyncio import _overlapped
+from asyncio import windows_events
-class UpperProto(protocols.Protocol):
+class UpperProto(asyncio.Protocol):
def __init__(self):
self.buf = []
@@ -35,7 +30,7 @@ class UpperProto(protocols.Protocol):
class ProactorTests(unittest.TestCase):
def setUp(self):
- self.loop = windows_events.ProactorEventLoop()
+ self.loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(None)
def tearDown(self):
@@ -44,7 +39,7 @@ class ProactorTests(unittest.TestCase):
def test_close(self):
a, b = self.loop._socketpair()
- trans = self.loop._make_socket_transport(a, protocols.Protocol())
+ trans = self.loop._make_socket_transport(a, asyncio.Protocol())
f = asyncio.async(self.loop.sock_recv(b, 100))
trans.close()
self.loop.run_until_complete(f)
@@ -67,7 +62,7 @@ class ProactorTests(unittest.TestCase):
with self.assertRaises(FileNotFoundError):
yield from self.loop.create_pipe_connection(
- protocols.Protocol, ADDRESS)
+ asyncio.Protocol, ADDRESS)
[server] = yield from self.loop.start_serving_pipe(
UpperProto, ADDRESS)
@@ -75,11 +70,11 @@ class ProactorTests(unittest.TestCase):
clients = []
for i in range(5):
- stream_reader = streams.StreamReader(loop=self.loop)
- protocol = streams.StreamReaderProtocol(stream_reader)
+ stream_reader = asyncio.StreamReader(loop=self.loop)
+ protocol = asyncio.StreamReaderProtocol(stream_reader)
trans, proto = yield from self.loop.create_pipe_connection(
lambda: protocol, ADDRESS)
- self.assertIsInstance(trans, transports.Transport)
+ self.assertIsInstance(trans, asyncio.Transport)
self.assertEqual(protocol, proto)
clients.append((stream_reader, trans))
@@ -95,7 +90,7 @@ class ProactorTests(unittest.TestCase):
with self.assertRaises(FileNotFoundError):
yield from self.loop.create_pipe_connection(
- protocols.Protocol, ADDRESS)
+ asyncio.Protocol, ADDRESS)
return 'done'
@@ -130,7 +125,7 @@ class ProactorTests(unittest.TestCase):
f = self.loop._proactor.wait_for_handle(event, 10)
f.cancel()
start = self.loop.time()
- with self.assertRaises(futures.CancelledError):
+ with self.assertRaises(asyncio.CancelledError):
self.loop.run_until_complete(f)
elapsed = self.loop.time() - start
self.assertTrue(0 <= elapsed < 0.1, elapsed)