summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-10-18 15:13:43 -0700
committerGuido van Rossum <guido@dropbox.com>2013-10-18 15:13:43 -0700
commit3a23eea2c4a92526661fa9de1749a08174d829d3 (patch)
tree5091447f9e0b4836ea842ad4187cb2a4fc3bbcbe
parent02195b0398d4a2dfcda07cf08c46eb5b2325f1e6 (diff)
parentdc3ac2b623f3d2b29565d6bd6907a4855f2c2c51 (diff)
downloadtrollius-3a23eea2c4a92526661fa9de1749a08174d829d3.tar.gz
Bulk merge
-rw-r--r--asyncio/__init__.py (renamed from tulip/__init__.py)9
-rw-r--r--asyncio/base_events.py (renamed from tulip/base_events.py)0
-rw-r--r--asyncio/constants.py (renamed from tulip/constants.py)0
-rw-r--r--asyncio/events.py (renamed from tulip/events.py)0
-rw-r--r--asyncio/futures.py (renamed from tulip/futures.py)0
-rw-r--r--asyncio/locks.py (renamed from tulip/locks.py)0
-rw-r--r--asyncio/log.py (renamed from tulip/log.py)2
-rw-r--r--asyncio/proactor_events.py (renamed from tulip/proactor_events.py)10
-rw-r--r--asyncio/protocols.py (renamed from tulip/protocols.py)0
-rw-r--r--asyncio/queues.py (renamed from tulip/queues.py)0
-rw-r--r--asyncio/selector_events.py (renamed from tulip/selector_events.py)0
-rw-r--r--asyncio/selectors.py (renamed from tulip/selectors.py)0
-rw-r--r--asyncio/streams.py (renamed from tulip/streams.py)0
-rw-r--r--asyncio/tasks.py (renamed from tulip/tasks.py)4
-rw-r--r--asyncio/test_utils.py (renamed from tulip/test_utils.py)19
-rw-r--r--asyncio/transports.py (renamed from tulip/transports.py)0
-rw-r--r--asyncio/unix_events.py (renamed from tulip/unix_events.py)0
-rw-r--r--asyncio/windows_events.py (renamed from tulip/windows_events.py)6
-rw-r--r--asyncio/windows_utils.py (renamed from tulip/windows_utils.py)0
-rw-r--r--examples/child_process.py40
-rw-r--r--examples/fetch0.py2
-rw-r--r--examples/fetch1.py2
-rw-r--r--examples/fetch2.py2
-rw-r--r--examples/fetch3.py2
-rw-r--r--examples/sink.py4
-rw-r--r--examples/source.py4
-rw-r--r--examples/stacks.py2
-rwxr-xr-xexamples/tcp_echo.py18
-rwxr-xr-xexamples/udp_echo.py10
-rw-r--r--runtests.py2
-rw-r--r--setup.cfg2
-rw-r--r--setup.py4
-rw-r--r--tests/test_base_events.py (renamed from tests/base_events_test.py)32
-rw-r--r--tests/test_events.py (renamed from tests/events_test.py)26
-rw-r--r--tests/test_futures.py (renamed from tests/futures_test.py)20
-rw-r--r--tests/test_locks.py (renamed from tests/locks_test.py)10
-rw-r--r--tests/test_proactor_events.py (renamed from tests/proactor_events_test.py)38
-rw-r--r--tests/test_queues.py (renamed from tests/queues_test.py)12
-rw-r--r--tests/test_selector_events.py (renamed from tests/selector_events_test.py)30
-rw-r--r--tests/test_selectors.py (renamed from tests/selectors_test.py)2
-rw-r--r--tests/test_streams.py (renamed from tests/streams_test.py)10
-rw-r--r--tests/test_tasks.py (renamed from tests/tasks_test.py)8
-rw-r--r--tests/test_transports.py (renamed from tests/transports_test.py)2
-rw-r--r--tests/test_unix_events.py (renamed from tests/unix_events_test.py)44
-rw-r--r--tests/test_windows_events.py (renamed from tests/windows_events_test.py)20
-rw-r--r--tests/test_windows_utils.py (renamed from tests/windows_utils_test.py)10
-rwxr-xr-xupdate_stdlib.sh54
47 files changed, 274 insertions, 188 deletions
diff --git a/tulip/__init__.py b/asyncio/__init__.py
index faf307f..afc444d 100644
--- a/tulip/__init__.py
+++ b/asyncio/__init__.py
@@ -1,7 +1,14 @@
-"""Tulip 2.0, tracking PEP 3156."""
+"""The asyncio package, tracking PEP 3156."""
import sys
+# The selectors module is in the stdlib in Python 3.4 but not in 3.3.
+# Do this first, so the other submodules can use "from . import selectors".
+try:
+ import selectors # Will also be exported.
+except ImportError:
+ from . import selectors
+
# This relies on each of the submodules having an __all__ variable.
from .futures import *
from .events import *
diff --git a/tulip/base_events.py b/asyncio/base_events.py
index 5f1bff7..5f1bff7 100644
--- a/tulip/base_events.py
+++ b/asyncio/base_events.py
diff --git a/tulip/constants.py b/asyncio/constants.py
index 79c3b93..79c3b93 100644
--- a/tulip/constants.py
+++ b/asyncio/constants.py
diff --git a/tulip/events.py b/asyncio/events.py
index 6ca5668..6ca5668 100644
--- a/tulip/events.py
+++ b/asyncio/events.py
diff --git a/tulip/futures.py b/asyncio/futures.py
index db27838..db27838 100644
--- a/tulip/futures.py
+++ b/asyncio/futures.py
diff --git a/tulip/locks.py b/asyncio/locks.py
index 06edbbc..06edbbc 100644
--- a/tulip/locks.py
+++ b/asyncio/locks.py
diff --git a/tulip/log.py b/asyncio/log.py
index 5f3534c..23a7074 100644
--- a/tulip/log.py
+++ b/asyncio/log.py
@@ -1,4 +1,4 @@
-"""Tulip logging configuration"""
+"""Logging configuration."""
import logging
diff --git a/tulip/proactor_events.py b/asyncio/proactor_events.py
index 2a2701a..665569f 100644
--- a/tulip/proactor_events.py
+++ b/asyncio/proactor_events.py
@@ -221,9 +221,15 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport,
def _set_extra(self, sock):
self._extra['socket'] = sock
- self._extra['sockname'] = sock.getsockname()
+ try:
+ self._extra['sockname'] = sock.getsockname()
+ except (socket.error, AttributeError):
+ pass
if 'peername' not in self._extra:
- self._extra['peername'] = sock.getpeername()
+ try:
+ self._extra['peername'] = sock.getpeername()
+ except (socket.error, AttributeError):
+ pass
def can_write_eof(self):
return True
diff --git a/tulip/protocols.py b/asyncio/protocols.py
index d3a8685..d3a8685 100644
--- a/tulip/protocols.py
+++ b/asyncio/protocols.py
diff --git a/tulip/queues.py b/asyncio/queues.py
index 536de1c..536de1c 100644
--- a/tulip/queues.py
+++ b/asyncio/queues.py
diff --git a/tulip/selector_events.py b/asyncio/selector_events.py
index 63164f0..63164f0 100644
--- a/tulip/selector_events.py
+++ b/asyncio/selector_events.py
diff --git a/tulip/selectors.py b/asyncio/selectors.py
index fe027f0..fe027f0 100644
--- a/tulip/selectors.py
+++ b/asyncio/selectors.py
diff --git a/tulip/streams.py b/asyncio/streams.py
index e995368..e995368 100644
--- a/tulip/streams.py
+++ b/asyncio/streams.py
diff --git a/tulip/tasks.py b/asyncio/tasks.py
index 7aba698..6385017 100644
--- a/tulip/tasks.py
+++ b/asyncio/tasks.py
@@ -331,7 +331,7 @@ def wait(fs, *, loop=None, timeout=None, return_when=ALL_COMPLETED):
Usage:
- done, pending = yield from tulip.wait(fs)
+ done, pending = yield from asyncio.wait(fs)
Note: This does not raise TimeoutError! Futures that aren't done
when the timeout occurs are returned in the second set.
@@ -365,7 +365,7 @@ def wait_for(fut, timeout, *, loop=None):
Usage:
- result = yield from tulip.wait_for(fut, 10.0)
+ result = yield from asyncio.wait_for(fut, 10.0)
"""
if loop is None:
diff --git a/tulip/test_utils.py b/asyncio/test_utils.py
index fdf629d..91bbedb 100644
--- a/tulip/test_utils.py
+++ b/asyncio/test_utils.py
@@ -15,10 +15,10 @@ try:
except ImportError: # pragma: no cover
ssl = None
-import tulip
-from tulip import base_events
-from tulip import events
-from tulip import selectors
+from . import tasks
+from . import base_events
+from . import events
+from . import selectors
if sys.platform == 'win32': # pragma: no cover
@@ -35,11 +35,11 @@ def dummy_ssl_context():
def run_briefly(loop):
- @tulip.coroutine
+ @tasks.coroutine
def once():
pass
gen = once()
- t = tulip.Task(gen, loop=loop)
+ t = tasks.Task(gen, loop=loop)
try:
loop.run_until_complete(t)
finally:
@@ -72,7 +72,14 @@ def run_test_server(*, host='127.0.0.1', port=0, use_ssl=False):
class SSLWSGIServer(SilentWSGIServer):
def finish_request(self, request, client_address):
+ # The relative location of our test directory (which
+ # contains the sample key and certificate files) differs
+ # between the stdlib and stand-alone Tulip/asyncio.
+ # Prefer our own if we can find it.
here = os.path.join(os.path.dirname(__file__), '..', 'tests')
+ if not os.path.isdir(here):
+ here = os.path.join(os.path.dirname(os.__file__),
+ 'test', 'test_asyncio')
keyfile = os.path.join(here, 'sample.key')
certfile = os.path.join(here, 'sample.crt')
ssock = ssl.wrap_socket(request,
diff --git a/tulip/transports.py b/asyncio/transports.py
index 8c6b189..8c6b189 100644
--- a/tulip/transports.py
+++ b/asyncio/transports.py
diff --git a/tulip/unix_events.py b/asyncio/unix_events.py
index a234f4f..a234f4f 100644
--- a/tulip/unix_events.py
+++ b/asyncio/unix_events.py
diff --git a/tulip/windows_events.py b/asyncio/windows_events.py
index ad53a8e..bbeada8 100644
--- a/tulip/windows_events.py
+++ b/asyncio/windows_events.py
@@ -11,9 +11,13 @@ from . import proactor_events
from . import selector_events
from . import tasks
from . import windows_utils
-from . import _overlapped
from .log import logger
+try:
+ import _overlapped
+except ImportError:
+ from . import _overlapped
+
__all__ = ['SelectorEventLoop', 'ProactorEventLoop', 'IocpProactor']
diff --git a/tulip/windows_utils.py b/asyncio/windows_utils.py
index 04b43e9..04b43e9 100644
--- a/tulip/windows_utils.py
+++ b/asyncio/windows_utils.py
diff --git a/examples/child_process.py b/examples/child_process.py
index 5a88faa..ef31e68 100644
--- a/examples/child_process.py
+++ b/examples/child_process.py
@@ -8,18 +8,18 @@ import os
import sys
try:
- import tulip
+ import asyncio
except ImportError:
- # tulip is not installed
+ # asyncio is not installed
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
- import tulip
+ import asyncio
-from tulip import streams
-from tulip import protocols
+from asyncio import streams
+from asyncio import protocols
if sys.platform == 'win32':
- from tulip.windows_utils import Popen, PIPE
- from tulip.windows_events import ProactorEventLoop
+ from asyncio.windows_utils import Popen, PIPE
+ from asyncio.windows_events import ProactorEventLoop
else:
from subprocess import Popen, PIPE
@@ -27,20 +27,20 @@ else:
# Return a write-only transport wrapping a writable pipe
#
-@tulip.coroutine
+@asyncio.coroutine
def connect_write_pipe(file):
- loop = tulip.get_event_loop()
+ loop = asyncio.get_event_loop()
protocol = protocols.Protocol()
- transport, _ = yield from loop.connect_write_pipe(tulip.Protocol, file)
+ transport, _ = yield from loop.connect_write_pipe(asyncio.Protocol, file)
return transport
#
# Wrap a readable pipe in a stream
#
-@tulip.coroutine
+@asyncio.coroutine
def connect_read_pipe(file):
- loop = tulip.get_event_loop()
+ loop = asyncio.get_event_loop()
stream_reader = streams.StreamReader(loop=loop)
def factory():
return streams.StreamReaderProtocol(stream_reader)
@@ -52,7 +52,7 @@ def connect_read_pipe(file):
# Example
#
-@tulip.coroutine
+@asyncio.coroutine
def main(loop):
# program which prints evaluation of each expression from stdin
code = r'''if 1:
@@ -88,8 +88,8 @@ def main(loop):
# interact with subprocess
name = {stdout:'OUT', stderr:'ERR'}
- registered = {tulip.Task(stderr.readline()): stderr,
- tulip.Task(stdout.readline()): stdout}
+ registered = {asyncio.Task(stderr.readline()): stderr,
+ asyncio.Task(stdout.readline()): stdout}
while registered:
# write command
cmd = next(commands, None)
@@ -102,8 +102,8 @@ def main(loop):
# get and print lines from stdout, stderr
timeout = None
while registered:
- done, pending = yield from tulip.wait(
- registered, timeout=timeout, return_when=tulip.FIRST_COMPLETED)
+ done, pending = yield from asyncio.wait(
+ registered, timeout=timeout, return_when=asyncio.FIRST_COMPLETED)
if not done:
break
for f in done:
@@ -111,7 +111,7 @@ def main(loop):
res = f.result()
print(name[stream], res.decode('ascii').rstrip())
if res != b'':
- registered[tulip.Task(stream.readline())] = stream
+ registered[asyncio.Task(stream.readline())] = stream
timeout = 0.0
stdout_transport.close()
@@ -120,8 +120,8 @@ def main(loop):
if __name__ == '__main__':
if sys.platform == 'win32':
loop = ProactorEventLoop()
- tulip.set_event_loop(loop)
+ asyncio.set_event_loop(loop)
else:
- loop = tulip.get_event_loop()
+ loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
loop.close()
diff --git a/examples/fetch0.py b/examples/fetch0.py
index 84edaa2..ac4d5d9 100644
--- a/examples/fetch0.py
+++ b/examples/fetch0.py
@@ -2,7 +2,7 @@
import sys
-from tulip import *
+from asyncio import *
@coroutine
diff --git a/examples/fetch1.py b/examples/fetch1.py
index 57e66e6..6d99262 100644
--- a/examples/fetch1.py
+++ b/examples/fetch1.py
@@ -6,7 +6,7 @@ This version adds URL parsing (including SSL) and a Response object.
import sys
import urllib.parse
-from tulip import *
+from asyncio import *
class Response:
diff --git a/examples/fetch2.py b/examples/fetch2.py
index ca250d6..0899123 100644
--- a/examples/fetch2.py
+++ b/examples/fetch2.py
@@ -7,7 +7,7 @@ import sys
import urllib.parse
from http.client import BadStatusLine
-from tulip import *
+from asyncio import *
class Request:
diff --git a/examples/fetch3.py b/examples/fetch3.py
index 3b2c8ae..fac880f 100644
--- a/examples/fetch3.py
+++ b/examples/fetch3.py
@@ -8,7 +8,7 @@ import sys
import urllib.parse
from http.client import BadStatusLine
-from tulip import *
+from asyncio import *
class ConnectionPool:
diff --git a/examples/sink.py b/examples/sink.py
index c94574a..b5edc3a 100644
--- a/examples/sink.py
+++ b/examples/sink.py
@@ -3,7 +3,7 @@
import argparse
import sys
-from tulip import *
+from asyncio import *
ARGS = argparse.ArgumentParser(description="TCP data sink example.")
ARGS.add_argument(
@@ -63,7 +63,7 @@ def main():
global args
args = ARGS.parse_args()
if args.iocp:
- from tulip.windows_events import ProactorEventLoop
+ from asyncio.windows_events import ProactorEventLoop
loop = ProactorEventLoop()
set_event_loop(loop)
else:
diff --git a/examples/source.py b/examples/source.py
index 933739b..c36f147 100644
--- a/examples/source.py
+++ b/examples/source.py
@@ -3,7 +3,7 @@
import argparse
import sys
-from tulip import *
+from asyncio import *
ARGS = argparse.ArgumentParser(description="TCP data sink example.")
@@ -77,7 +77,7 @@ def main():
global args
args = ARGS.parse_args()
if args.iocp:
- from tulip.windows_events import ProactorEventLoop
+ from asyncio.windows_events import ProactorEventLoop
loop = ProactorEventLoop()
set_event_loop(loop)
else:
diff --git a/examples/stacks.py b/examples/stacks.py
index 77a99cf..371d31f 100644
--- a/examples/stacks.py
+++ b/examples/stacks.py
@@ -1,7 +1,7 @@
"""Crude demo for print_stack()."""
-from tulip import *
+from asyncio import *
@coroutine
diff --git a/examples/tcp_echo.py b/examples/tcp_echo.py
index 9ecc480..3d9b39c 100755
--- a/examples/tcp_echo.py
+++ b/examples/tcp_echo.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python3
"""TCP echo server example."""
import argparse
-import tulip
+import asyncio
try:
import signal
except ImportError:
signal = None
-class EchoServer(tulip.Protocol):
+class EchoServer(asyncio.Protocol):
TIMEOUT = 5.0
@@ -21,7 +21,7 @@ class EchoServer(tulip.Protocol):
self.transport = transport
# start 5 seconds timeout timer
- self.h_timeout = tulip.get_event_loop().call_later(
+ self.h_timeout = asyncio.get_event_loop().call_later(
self.TIMEOUT, self.timeout)
def data_received(self, data):
@@ -30,7 +30,7 @@ class EchoServer(tulip.Protocol):
# restart timeout timer
self.h_timeout.cancel()
- self.h_timeout = tulip.get_event_loop().call_later(
+ self.h_timeout = asyncio.get_event_loop().call_later(
self.TIMEOUT, self.timeout)
def eof_received(self):
@@ -41,7 +41,7 @@ class EchoServer(tulip.Protocol):
self.h_timeout.cancel()
-class EchoClient(tulip.Protocol):
+class EchoClient(asyncio.Protocol):
message = 'This is the message. It will be echoed.'
@@ -54,18 +54,18 @@ class EchoClient(tulip.Protocol):
print('data received:', data)
# disconnect after 10 seconds
- tulip.get_event_loop().call_later(10.0, self.transport.close)
+ asyncio.get_event_loop().call_later(10.0, self.transport.close)
def eof_received(self):
pass
def connection_lost(self, exc):
print('connection lost:', exc)
- tulip.get_event_loop().stop()
+ asyncio.get_event_loop().stop()
def start_client(loop, host, port):
- t = tulip.Task(loop.create_connection(EchoClient, host, port))
+ t = asyncio.Task(loop.create_connection(EchoClient, host, port))
loop.run_until_complete(t)
@@ -101,7 +101,7 @@ if __name__ == '__main__':
print('Please specify --server or --client\n')
ARGS.print_help()
else:
- loop = tulip.get_event_loop()
+ loop = asyncio.get_event_loop()
if signal is not None:
loop.add_signal_handler(signal.SIGINT, loop.stop)
diff --git a/examples/udp_echo.py b/examples/udp_echo.py
index 0347bfb..8e95d29 100755
--- a/examples/udp_echo.py
+++ b/examples/udp_echo.py
@@ -2,7 +2,7 @@
"""UDP echo example."""
import argparse
import sys
-import tulip
+import asyncio
try:
import signal
except ImportError:
@@ -45,18 +45,18 @@ class MyClientUdpEchoProtocol:
def connection_lost(self, exc):
print('closing transport', exc)
- loop = tulip.get_event_loop()
+ loop = asyncio.get_event_loop()
loop.stop()
def start_server(loop, addr):
- t = tulip.Task(loop.create_datagram_endpoint(
+ t = asyncio.Task(loop.create_datagram_endpoint(
MyServerUdpEchoProtocol, local_addr=addr))
loop.run_until_complete(t)
def start_client(loop, addr):
- t = tulip.Task(loop.create_datagram_endpoint(
+ t = asyncio.Task(loop.create_datagram_endpoint(
MyClientUdpEchoProtocol, remote_addr=addr))
loop.run_until_complete(t)
@@ -86,7 +86,7 @@ if __name__ == '__main__':
print('Please specify --server or --client\n')
ARGS.print_help()
else:
- loop = tulip.get_event_loop()
+ loop = asyncio.get_event_loop()
if signal is not None:
loop.add_signal_handler(signal.SIGINT, loop.stop)
diff --git a/runtests.py b/runtests.py
index 287d036..b85cce8 100644
--- a/runtests.py
+++ b/runtests.py
@@ -5,7 +5,7 @@ Usage:
Patterns are matched against the fully qualified name of the test,
including package, module, class and method,
-e.g. 'tests.events_test.PolicyTests.testPolicy'.
+e.g. 'tests.test_events.PolicyTests.testPolicy'.
For full help, try --help.
diff --git a/setup.cfg b/setup.cfg
index 0260f9d..172844c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,2 @@
[build_ext]
-build_lib=tulip
+build_lib=asyncio
diff --git a/setup.py b/setup.py
index dcaee96..fad16e7 100644
--- a/setup.py
+++ b/setup.py
@@ -6,9 +6,9 @@ if os.name == 'nt':
ext = Extension('_overlapped', ['overlapped.c'], libraries=['ws2_32'])
extensions.append(ext)
-setup(name='tulip',
+setup(name='asyncio',
description="reference implementation of PEP 3156",
url='http://www.python.org/dev/peps/pep-3156/',
- packages=['tulip'],
+ packages=['asyncio'],
ext_modules=extensions
)
diff --git a/tests/base_events_test.py b/tests/test_base_events.py
index 60fb007..db15244 100644
--- a/tests/base_events_test.py
+++ b/tests/test_base_events.py
@@ -6,12 +6,12 @@ import time
import unittest
import unittest.mock
-from tulip import base_events
-from tulip import events
-from tulip import futures
-from tulip import protocols
-from tulip import tasks
-from tulip import test_utils
+from asyncio import base_events
+from asyncio import events
+from asyncio import futures
+from asyncio import protocols
+from asyncio import tasks
+from asyncio import test_utils
class BaseEventLoopTests(unittest.TestCase):
@@ -182,8 +182,8 @@ class BaseEventLoopTests(unittest.TestCase):
self.assertEqual([h2], self.loop._scheduled)
self.assertTrue(self.loop._process_events.called)
- @unittest.mock.patch('tulip.base_events.time')
- @unittest.mock.patch('tulip.base_events.logger')
+ @unittest.mock.patch('asyncio.base_events.time')
+ @unittest.mock.patch('asyncio.base_events.logger')
def test__run_once_logging(self, m_logging, m_time):
# Log to INFO level if timeout > 1.0 sec.
idx = -1
@@ -300,7 +300,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
def tearDown(self):
self.loop.close()
- @unittest.mock.patch('tulip.base_events.socket')
+ @unittest.mock.patch('asyncio.base_events.socket')
def test_create_connection_multiple_errors(self, m_socket):
class MyProto(protocols.Protocol):
@@ -390,7 +390,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
with self.assertRaises(OSError):
self.loop.run_until_complete(coro)
- @unittest.mock.patch('tulip.base_events.socket')
+ @unittest.mock.patch('asyncio.base_events.socket')
def test_create_connection_multiple_errors_local_addr(self, m_socket):
def bind(addr):
@@ -475,7 +475,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
f = self.loop.create_server(MyProto, '0.0.0.0', 0)
self.assertRaises(OSError, self.loop.run_until_complete, f)
- @unittest.mock.patch('tulip.base_events.socket')
+ @unittest.mock.patch('asyncio.base_events.socket')
def test_create_server_cant_bind(self, m_socket):
class Err(OSError):
@@ -490,7 +490,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
self.assertRaises(OSError, self.loop.run_until_complete, fut)
self.assertTrue(m_sock.close.called)
- @unittest.mock.patch('tulip.base_events.socket')
+ @unittest.mock.patch('asyncio.base_events.socket')
def test_create_datagram_endpoint_no_addrinfo(self, m_socket):
m_socket.getaddrinfo.return_value = []
@@ -518,7 +518,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
self.assertRaises(
OSError, self.loop.run_until_complete, coro)
- @unittest.mock.patch('tulip.base_events.socket')
+ @unittest.mock.patch('asyncio.base_events.socket')
def test_create_datagram_endpoint_socket_err(self, m_socket):
m_socket.getaddrinfo = socket.getaddrinfo
m_socket.socket.side_effect = OSError
@@ -540,7 +540,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
self.assertRaises(
ValueError, self.loop.run_until_complete, coro)
- @unittest.mock.patch('tulip.base_events.socket')
+ @unittest.mock.patch('asyncio.base_events.socket')
def test_create_datagram_endpoint_setblk_err(self, m_socket):
m_socket.socket.return_value.setblocking.side_effect = OSError
@@ -556,7 +556,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
protocols.DatagramProtocol)
self.assertRaises(ValueError, self.loop.run_until_complete, coro)
- @unittest.mock.patch('tulip.base_events.socket')
+ @unittest.mock.patch('asyncio.base_events.socket')
def test_create_datagram_endpoint_cant_bind(self, m_socket):
class Err(OSError):
pass
@@ -579,7 +579,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
self.loop._accept_connection(MyProto, sock)
self.assertFalse(sock.close.called)
- @unittest.mock.patch('tulip.selector_events.logger')
+ @unittest.mock.patch('asyncio.selector_events.logger')
def test_accept_connection_exception(self, m_log):
sock = unittest.mock.Mock()
sock.fileno.return_value = 10
diff --git a/tests/events_test.py b/tests/test_events.py
index 5abd0c4..4921e7f 100644
--- a/tests/events_test.py
+++ b/tests/test_events.py
@@ -20,14 +20,14 @@ import unittest.mock
from test.support import find_unused_port
-from tulip import futures
-from tulip import events
-from tulip import transports
-from tulip import protocols
-from tulip import selector_events
-from tulip import tasks
-from tulip import test_utils
-from tulip import locks
+from asyncio import futures
+from asyncio import events
+from asyncio import transports
+from asyncio import protocols
+from asyncio import selector_events
+from asyncio import tasks
+from asyncio import test_utils
+from asyncio import locks
class MyProto(protocols.Protocol):
@@ -1223,7 +1223,7 @@ class EventLoopTestsMixin:
if sys.platform == 'win32':
- from tulip import windows_events
+ from asyncio import windows_events
class SelectEventLoopTests(EventLoopTestsMixin, unittest.TestCase):
@@ -1257,8 +1257,8 @@ if sys.platform == 'win32':
raise unittest.SkipTest(
"IocpEventLoop does not have create_datagram_endpoint()")
else:
- from tulip import selectors
- from tulip import unix_events
+ from asyncio import selectors
+ from asyncio import unix_events
if hasattr(selectors, 'KqueueSelector'):
class KqueueEventLoopTests(EventLoopTestsMixin, unittest.TestCase):
@@ -1320,7 +1320,7 @@ class HandleTests(unittest.TestCase):
self.assertRaises(
AssertionError, events.make_handle, h1, ())
- @unittest.mock.patch('tulip.events.logger')
+ @unittest.mock.patch('asyncio.events.logger')
def test_callback_with_exception(self, log):
def callback():
raise ValueError()
@@ -1521,7 +1521,7 @@ class PolicyTests(unittest.TestCase):
policy.set_event_loop(None)
self.assertRaises(AssertionError, policy.get_event_loop)
- @unittest.mock.patch('tulip.events.threading.current_thread')
+ @unittest.mock.patch('asyncio.events.threading.current_thread')
def test_get_event_loop_thread(self, m_current_thread):
def f():
diff --git a/tests/futures_test.py b/tests/test_futures.py
index 13a1dd9..ccea2ff 100644
--- a/tests/futures_test.py
+++ b/tests/test_futures.py
@@ -5,9 +5,9 @@ import threading
import unittest
import unittest.mock
-from tulip import events
-from tulip import futures
-from tulip import test_utils
+from asyncio import events
+from asyncio import futures
+from asyncio import test_utils
def _fakefunc(f):
@@ -170,20 +170,20 @@ class FutureTests(unittest.TestCase):
self.assertRaises(AssertionError, test)
fut.cancel()
- @unittest.mock.patch('tulip.futures.logger')
+ @unittest.mock.patch('asyncio.futures.logger')
def test_tb_logger_abandoned(self, m_log):
fut = futures.Future(loop=self.loop)
del fut
self.assertFalse(m_log.error.called)
- @unittest.mock.patch('tulip.futures.logger')
+ @unittest.mock.patch('asyncio.futures.logger')
def test_tb_logger_result_unretrieved(self, m_log):
fut = futures.Future(loop=self.loop)
fut.set_result(42)
del fut
self.assertFalse(m_log.error.called)
- @unittest.mock.patch('tulip.futures.logger')
+ @unittest.mock.patch('asyncio.futures.logger')
def test_tb_logger_result_retrieved(self, m_log):
fut = futures.Future(loop=self.loop)
fut.set_result(42)
@@ -191,7 +191,7 @@ class FutureTests(unittest.TestCase):
del fut
self.assertFalse(m_log.error.called)
- @unittest.mock.patch('tulip.futures.logger')
+ @unittest.mock.patch('asyncio.futures.logger')
def test_tb_logger_exception_unretrieved(self, m_log):
fut = futures.Future(loop=self.loop)
fut.set_exception(RuntimeError('boom'))
@@ -199,7 +199,7 @@ class FutureTests(unittest.TestCase):
test_utils.run_briefly(self.loop)
self.assertTrue(m_log.error.called)
- @unittest.mock.patch('tulip.futures.logger')
+ @unittest.mock.patch('asyncio.futures.logger')
def test_tb_logger_exception_retrieved(self, m_log):
fut = futures.Future(loop=self.loop)
fut.set_exception(RuntimeError('boom'))
@@ -207,7 +207,7 @@ class FutureTests(unittest.TestCase):
del fut
self.assertFalse(m_log.error.called)
- @unittest.mock.patch('tulip.futures.logger')
+ @unittest.mock.patch('asyncio.futures.logger')
def test_tb_logger_exception_result_retrieved(self, m_log):
fut = futures.Future(loop=self.loop)
fut.set_exception(RuntimeError('boom'))
@@ -232,7 +232,7 @@ class FutureTests(unittest.TestCase):
f2 = futures.wrap_future(f1)
self.assertIs(f1, f2)
- @unittest.mock.patch('tulip.futures.events')
+ @unittest.mock.patch('asyncio.futures.events')
def test_wrap_future_use_global_loop(self, m_events):
def run(arg):
return (arg, threading.get_ident())
diff --git a/tests/locks_test.py b/tests/test_locks.py
index 7c138ee..31b4d64 100644
--- a/tests/locks_test.py
+++ b/tests/test_locks.py
@@ -3,11 +3,11 @@
import unittest
import unittest.mock
-from tulip import events
-from tulip import futures
-from tulip import locks
-from tulip import tasks
-from tulip import test_utils
+from asyncio import events
+from asyncio import futures
+from asyncio import locks
+from asyncio import tasks
+from asyncio import test_utils
class LockTests(unittest.TestCase):
diff --git a/tests/proactor_events_test.py b/tests/test_proactor_events.py
index c124083..05d1606 100644
--- a/tests/proactor_events_test.py
+++ b/tests/test_proactor_events.py
@@ -4,12 +4,12 @@ import socket
import unittest
import unittest.mock
-import tulip
-from tulip.proactor_events import BaseProactorEventLoop
-from tulip.proactor_events import _ProactorSocketTransport
-from tulip.proactor_events import _ProactorWritePipeTransport
-from tulip.proactor_events import _ProactorDuplexPipeTransport
-from tulip import test_utils
+import asyncio
+from asyncio.proactor_events import BaseProactorEventLoop
+from asyncio.proactor_events import _ProactorSocketTransport
+from asyncio.proactor_events import _ProactorWritePipeTransport
+from asyncio.proactor_events import _ProactorDuplexPipeTransport
+from asyncio import test_utils
class ProactorSocketTransportTests(unittest.TestCase):
@@ -18,11 +18,11 @@ class ProactorSocketTransportTests(unittest.TestCase):
self.loop = test_utils.TestLoop()
self.proactor = unittest.mock.Mock()
self.loop._proactor = self.proactor
- self.protocol = test_utils.make_test_protocol(tulip.Protocol)
+ self.protocol = test_utils.make_test_protocol(asyncio.Protocol)
self.sock = unittest.mock.Mock(socket.socket)
def test_ctor(self):
- fut = tulip.Future(loop=self.loop)
+ fut = asyncio.Future(loop=self.loop)
tr = _ProactorSocketTransport(
self.loop, self.sock, self.protocol, fut)
test_utils.run_briefly(self.loop)
@@ -38,7 +38,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
self.assertFalse(self.protocol.eof_received.called)
def test_loop_reading_data(self):
- res = tulip.Future(loop=self.loop)
+ res = asyncio.Future(loop=self.loop)
res.set_result(b'data')
tr = _ProactorSocketTransport(self.loop, self.sock, self.protocol)
@@ -49,7 +49,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
self.protocol.data_received.assert_called_with(b'data')
def test_loop_reading_no_data(self):
- res = tulip.Future(loop=self.loop)
+ res = asyncio.Future(loop=self.loop)
res.set_result(b'')
tr = _ProactorSocketTransport(self.loop, self.sock, self.protocol)
@@ -135,7 +135,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
self.loop._proactor.send.return_value.add_done_callback.\
assert_called_with(tr._loop_writing)
- @unittest.mock.patch('tulip.proactor_events.logger')
+ @unittest.mock.patch('asyncio.proactor_events.logger')
def test_loop_writing_err(self, m_log):
err = self.loop._proactor.send.side_effect = OSError()
tr = _ProactorSocketTransport(self.loop, self.sock, self.protocol)
@@ -154,7 +154,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
m_log.warning.assert_called_with('socket.send() raised exception.')
def test_loop_writing_stop(self):
- fut = tulip.Future(loop=self.loop)
+ fut = asyncio.Future(loop=self.loop)
fut.set_result(b'data')
tr = _ProactorSocketTransport(self.loop, self.sock, self.protocol)
@@ -163,7 +163,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
self.assertIsNone(tr._write_fut)
def test_loop_writing_closing(self):
- fut = tulip.Future(loop=self.loop)
+ fut = asyncio.Future(loop=self.loop)
fut.set_result(1)
tr = _ProactorSocketTransport(self.loop, self.sock, self.protocol)
@@ -207,7 +207,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
test_utils.run_briefly(self.loop)
self.assertFalse(self.protocol.connection_lost.called)
- @unittest.mock.patch('tulip.proactor_events.logger')
+ @unittest.mock.patch('asyncio.proactor_events.logger')
def test_fatal_error(self, m_logging):
tr = _ProactorSocketTransport(self.loop, self.sock, self.protocol)
tr._force_close = unittest.mock.Mock()
@@ -263,7 +263,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
def test_write_eof_buffer(self):
tr = _ProactorSocketTransport(self.loop, self.sock, self.protocol)
- f = tulip.Future(loop=self.loop)
+ f = asyncio.Future(loop=self.loop)
tr._loop._proactor.send.return_value = f
tr.write(b'data')
tr.write_eof()
@@ -287,7 +287,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
def test_write_eof_buffer_write_pipe(self):
tr = _ProactorWritePipeTransport(self.loop, self.sock, self.protocol)
- f = tulip.Future(loop=self.loop)
+ f = asyncio.Future(loop=self.loop)
tr._loop._proactor.send.return_value = f
tr.write(b'data')
tr.write_eof()
@@ -313,7 +313,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
self.loop, self.sock, self.protocol)
futures = []
for msg in [b'data1', b'data2', b'data3', b'data4', b'']:
- f = tulip.Future(loop=self.loop)
+ f = asyncio.Future(loop=self.loop)
f.set_result(msg)
futures.append(f)
self.loop._proactor.recv.side_effect = futures
@@ -432,7 +432,7 @@ class BaseProactorEventLoopTests(unittest.TestCase):
def test_process_events(self):
self.loop._process_events([])
- @unittest.mock.patch('tulip.proactor_events.logger')
+ @unittest.mock.patch('asyncio.proactor_events.logger')
def test_create_server(self, m_log):
pf = unittest.mock.Mock()
call_soon = self.loop.call_soon = unittest.mock.Mock()
@@ -468,7 +468,7 @@ class BaseProactorEventLoopTests(unittest.TestCase):
loop = call_soon.call_args[0][0]
# cancelled
- fut = tulip.Future(loop=self.loop)
+ fut = asyncio.Future(loop=self.loop)
fut.cancel()
loop(fut)
self.assertTrue(self.sock.close.called)
diff --git a/tests/queues_test.py b/tests/test_queues.py
index ae1e3a1..8af4ee7 100644
--- a/tests/queues_test.py
+++ b/tests/test_queues.py
@@ -3,12 +3,12 @@
import unittest
import unittest.mock
-from tulip import events
-from tulip import futures
-from tulip import locks
-from tulip import queues
-from tulip import tasks
-from tulip import test_utils
+from asyncio import events
+from asyncio import futures
+from asyncio import locks
+from asyncio import queues
+from asyncio import tasks
+from asyncio import test_utils
class _QueueTestBase(unittest.TestCase):
diff --git a/tests/selector_events_test.py b/tests/test_selector_events.py
index 25521c0..53728b8 100644
--- a/tests/selector_events_test.py
+++ b/tests/test_selector_events.py
@@ -13,15 +13,15 @@ try:
except ImportError:
ssl = None
-from tulip import futures
-from tulip import selectors
-from tulip import test_utils
-from tulip.protocols import DatagramProtocol, Protocol
-from tulip.selector_events import BaseSelectorEventLoop
-from tulip.selector_events import _SelectorTransport
-from tulip.selector_events import _SelectorSslTransport
-from tulip.selector_events import _SelectorSocketTransport
-from tulip.selector_events import _SelectorDatagramTransport
+from asyncio import futures
+from asyncio import selectors
+from asyncio import test_utils
+from asyncio.protocols import DatagramProtocol, Protocol
+from asyncio.selector_events import BaseSelectorEventLoop
+from asyncio.selector_events import _SelectorTransport
+from asyncio.selector_events import _SelectorSslTransport
+from asyncio.selector_events import _SelectorSocketTransport
+from asyncio.selector_events import _SelectorDatagramTransport
class TestBaseSelectorEventLoop(BaseSelectorEventLoop):
@@ -626,7 +626,7 @@ class SelectorTransportTests(unittest.TestCase):
self.assertFalse(self.loop.readers)
self.assertEqual(1, self.loop.remove_reader_count[7])
- @unittest.mock.patch('tulip.log.logger.exception')
+ @unittest.mock.patch('asyncio.log.logger.exception')
def test_fatal_error(self, m_exc):
exc = OSError()
tr = _SelectorTransport(self.loop, self.sock, self.protocol, None)
@@ -823,7 +823,7 @@ class SelectorSocketTransportTests(unittest.TestCase):
self.loop.assert_writer(7, transport._write_ready)
self.assertEqual(collections.deque([b'data']), transport._buffer)
- @unittest.mock.patch('tulip.selector_events.logger')
+ @unittest.mock.patch('asyncio.selector_events.logger')
def test_write_exception(self, m_log):
err = self.sock.send.side_effect = OSError()
@@ -937,7 +937,7 @@ class SelectorSocketTransportTests(unittest.TestCase):
transport._write_ready()
transport._fatal_error.assert_called_with(err)
- @unittest.mock.patch('tulip.selector_events.logger')
+ @unittest.mock.patch('asyncio.selector_events.logger')
def test_write_ready_exception_and_close(self, m_log):
self.sock.send.side_effect = OSError()
remove_writer = self.loop.remove_writer = unittest.mock.Mock()
@@ -1072,7 +1072,7 @@ class SelectorSslTransportTests(unittest.TestCase):
transport.write(b'data')
self.assertEqual(transport._conn_lost, 2)
- @unittest.mock.patch('tulip.selector_events.logger')
+ @unittest.mock.patch('asyncio.selector_events.logger')
def test_write_exception(self, m_log):
transport = self._make_one()
transport._conn_lost = 1
@@ -1325,7 +1325,7 @@ class SelectorDatagramTransportTests(unittest.TestCase):
self.assertEqual(
[(b'data', ('0.0.0.0', 12345))], list(transport._buffer))
- @unittest.mock.patch('tulip.selector_events.logger')
+ @unittest.mock.patch('asyncio.selector_events.logger')
def test_sendto_exception(self, m_log):
data = b'data'
err = self.sock.sendto.side_effect = OSError()
@@ -1475,7 +1475,7 @@ class SelectorDatagramTransportTests(unittest.TestCase):
self.assertTrue(transport._fatal_error.called)
- @unittest.mock.patch('tulip.log.logger.exception')
+ @unittest.mock.patch('asyncio.log.logger.exception')
def test_fatal_error_connected(self, m_exc):
transport = _SelectorDatagramTransport(
self.loop, self.sock, self.protocol, ('0.0.0.0', 1))
diff --git a/tests/selectors_test.py b/tests/test_selectors.py
index 0f74db0..2f7dc69 100644
--- a/tests/selectors_test.py
+++ b/tests/test_selectors.py
@@ -3,7 +3,7 @@
import unittest
import unittest.mock
-from tulip import selectors
+from asyncio import selectors
class FakeSelector(selectors.BaseSelector):
diff --git a/tests/streams_test.py b/tests/test_streams.py
index 1d52557..69e2246 100644
--- a/tests/streams_test.py
+++ b/tests/test_streams.py
@@ -8,10 +8,10 @@ try:
except ImportError:
ssl = None
-from tulip import events
-from tulip import streams
-from tulip import tasks
-from tulip import test_utils
+from asyncio import events
+from asyncio import streams
+from asyncio import tasks
+from asyncio import test_utils
class StreamReaderTests(unittest.TestCase):
@@ -29,7 +29,7 @@ class StreamReaderTests(unittest.TestCase):
self.loop.close()
gc.collect()
- @unittest.mock.patch('tulip.streams.events')
+ @unittest.mock.patch('asyncio.streams.events')
def test_ctor_global_loop(self, m_events):
stream = streams.StreamReader()
self.assertIs(stream._loop, m_events.get_event_loop.return_value)
diff --git a/tests/tasks_test.py b/tests/test_tasks.py
index 161bff8..57fb053 100644
--- a/tests/tasks_test.py
+++ b/tests/test_tasks.py
@@ -5,10 +5,10 @@ import unittest
import unittest.mock
from unittest.mock import Mock
-from tulip import events
-from tulip import futures
-from tulip import tasks
-from tulip import test_utils
+from asyncio import events
+from asyncio import futures
+from asyncio import tasks
+from asyncio import test_utils
class Dummy:
diff --git a/tests/transports_test.py b/tests/test_transports.py
index 3849293..53071af 100644
--- a/tests/transports_test.py
+++ b/tests/test_transports.py
@@ -3,7 +3,7 @@
import unittest
import unittest.mock
-from tulip import transports
+from asyncio import transports
class TransportTests(unittest.TestCase):
diff --git a/tests/unix_events_test.py b/tests/test_unix_events.py
index 5659d31..ccabeea 100644
--- a/tests/unix_events_test.py
+++ b/tests/test_unix_events.py
@@ -14,11 +14,11 @@ if sys.platform == 'win32':
raise unittest.SkipTest('UNIX only')
-from tulip import events
-from tulip import futures
-from tulip import protocols
-from tulip import test_utils
-from tulip import unix_events
+from asyncio import events
+from asyncio import futures
+from asyncio import protocols
+from asyncio import test_utils
+from asyncio import unix_events
@unittest.skipUnless(signal, 'Signals are not supported')
@@ -48,7 +48,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.loop._handle_signal(signal.NSIG + 1, ())
self.loop.remove_signal_handler.assert_called_with(signal.NSIG + 1)
- @unittest.mock.patch('tulip.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.signal')
def test_add_signal_handler_setup_error(self, m_signal):
m_signal.NSIG = signal.NSIG
m_signal.set_wakeup_fd.side_effect = ValueError
@@ -58,7 +58,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.loop.add_signal_handler,
signal.SIGINT, lambda: True)
- @unittest.mock.patch('tulip.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.signal')
def test_add_signal_handler(self, m_signal):
m_signal.NSIG = signal.NSIG
@@ -68,7 +68,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.assertTrue(isinstance(h, events.Handle))
self.assertEqual(h._callback, cb)
- @unittest.mock.patch('tulip.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.signal')
def test_add_signal_handler_install_error(self, m_signal):
m_signal.NSIG = signal.NSIG
@@ -86,8 +86,8 @@ class SelectorEventLoopTests(unittest.TestCase):
self.loop.add_signal_handler,
signal.SIGINT, lambda: True)
- @unittest.mock.patch('tulip.unix_events.signal')
- @unittest.mock.patch('tulip.unix_events.logger')
+ @unittest.mock.patch('asyncio.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.logger')
def test_add_signal_handler_install_error2(self, m_logging, m_signal):
m_signal.NSIG = signal.NSIG
@@ -103,8 +103,8 @@ class SelectorEventLoopTests(unittest.TestCase):
self.assertFalse(m_logging.info.called)
self.assertEqual(1, m_signal.set_wakeup_fd.call_count)
- @unittest.mock.patch('tulip.unix_events.signal')
- @unittest.mock.patch('tulip.unix_events.logger')
+ @unittest.mock.patch('asyncio.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.logger')
def test_add_signal_handler_install_error3(self, m_logging, m_signal):
class Err(OSError):
errno = errno.EINVAL
@@ -118,7 +118,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.assertFalse(m_logging.info.called)
self.assertEqual(2, m_signal.set_wakeup_fd.call_count)
- @unittest.mock.patch('tulip.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.signal')
def test_remove_signal_handler(self, m_signal):
m_signal.NSIG = signal.NSIG
@@ -131,7 +131,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.assertEqual(
(signal.SIGHUP, m_signal.SIG_DFL), m_signal.signal.call_args[0])
- @unittest.mock.patch('tulip.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.signal')
def test_remove_signal_handler_2(self, m_signal):
m_signal.NSIG = signal.NSIG
m_signal.SIGINT = signal.SIGINT
@@ -148,8 +148,8 @@ class SelectorEventLoopTests(unittest.TestCase):
(signal.SIGINT, m_signal.default_int_handler),
m_signal.signal.call_args[0])
- @unittest.mock.patch('tulip.unix_events.signal')
- @unittest.mock.patch('tulip.unix_events.logger')
+ @unittest.mock.patch('asyncio.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.logger')
def test_remove_signal_handler_cleanup_error(self, m_logging, m_signal):
m_signal.NSIG = signal.NSIG
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
@@ -159,7 +159,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.loop.remove_signal_handler(signal.SIGHUP)
self.assertTrue(m_logging.info)
- @unittest.mock.patch('tulip.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.signal')
def test_remove_signal_handler_error(self, m_signal):
m_signal.NSIG = signal.NSIG
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
@@ -169,7 +169,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.assertRaises(
OSError, self.loop.remove_signal_handler, signal.SIGHUP)
- @unittest.mock.patch('tulip.unix_events.signal')
+ @unittest.mock.patch('asyncio.unix_events.signal')
def test_remove_signal_handler_error2(self, m_signal):
m_signal.NSIG = signal.NSIG
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
@@ -270,7 +270,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self.assertFalse(m_WEXITSTATUS.called)
self.assertFalse(m_WTERMSIG.called)
- @unittest.mock.patch('tulip.unix_events.logger')
+ @unittest.mock.patch('asyncio.unix_events.logger')
@unittest.mock.patch('os.WTERMSIG')
@unittest.mock.patch('os.WEXITSTATUS')
@unittest.mock.patch('os.WIFSIGNALED')
@@ -360,7 +360,7 @@ class UnixReadPipeTransportTests(unittest.TestCase):
test_utils.run_briefly(self.loop)
self.assertFalse(self.protocol.data_received.called)
- @unittest.mock.patch('tulip.log.logger.exception')
+ @unittest.mock.patch('asyncio.log.logger.exception')
@unittest.mock.patch('os.read')
def test__read_ready_error(self, m_read, m_logexc):
tr = unix_events._UnixReadPipeTransport(
@@ -550,7 +550,7 @@ class UnixWritePipeTransportTests(unittest.TestCase):
self.loop.assert_writer(5, tr._write_ready)
self.assertEqual([b'data'], tr._buffer)
- @unittest.mock.patch('tulip.unix_events.logger')
+ @unittest.mock.patch('asyncio.unix_events.logger')
@unittest.mock.patch('os.write')
def test_write_err(self, m_write, m_log):
tr = unix_events._UnixWritePipeTransport(
@@ -648,7 +648,7 @@ class UnixWritePipeTransportTests(unittest.TestCase):
self.loop.assert_writer(5, tr._write_ready)
self.assertEqual([b'data'], tr._buffer)
- @unittest.mock.patch('tulip.log.logger.exception')
+ @unittest.mock.patch('asyncio.log.logger.exception')
@unittest.mock.patch('os.write')
def test__write_ready_err(self, m_write, m_logexc):
tr = unix_events._UnixWritePipeTransport(
diff --git a/tests/windows_events_test.py b/tests/test_windows_events.py
index 675728e..4b04073 100644
--- a/tests/windows_events_test.py
+++ b/tests/test_windows_events.py
@@ -1,13 +1,17 @@
import os
+import sys
import unittest
-import tulip
+if sys.platform != 'win32':
+ raise unittest.SkipTest('Windows only')
-from tulip import windows_events
-from tulip import protocols
-from tulip import streams
-from tulip import transports
-from tulip import test_utils
+import asyncio
+
+from asyncio import windows_events
+from asyncio import protocols
+from asyncio import streams
+from asyncio import transports
+from asyncio import test_utils
class UpperProto(protocols.Protocol):
@@ -28,7 +32,7 @@ class ProactorTests(unittest.TestCase):
def setUp(self):
self.loop = windows_events.ProactorEventLoop()
- tulip.set_event_loop(None)
+ asyncio.set_event_loop(None)
def tearDown(self):
self.loop.close()
@@ -37,7 +41,7 @@ class ProactorTests(unittest.TestCase):
def test_close(self):
a, b = self.loop._socketpair()
trans = self.loop._make_socket_transport(a, protocols.Protocol())
- f = tulip.async(self.loop.sock_recv(b, 100))
+ f = asyncio.async(self.loop.sock_recv(b, 100))
trans.close()
self.loop.run_until_complete(f)
self.assertEqual(f.result(), b'')
diff --git a/tests/windows_utils_test.py b/tests/test_windows_utils.py
index bd61463..3b6b036 100644
--- a/tests/windows_utils_test.py
+++ b/tests/test_windows_utils.py
@@ -4,14 +4,18 @@ import sys
import test.support
import unittest
import unittest.mock
+
+if sys.platform != 'win32':
+ raise unittest.SkipTest('Windows only')
+
import _winapi
-from tulip import windows_utils
+from asyncio import windows_utils
try:
import _overlapped
except ImportError:
- from tulip import _overlapped
+ from asyncio import _overlapped
class WinsocketpairTests(unittest.TestCase):
@@ -25,7 +29,7 @@ class WinsocketpairTests(unittest.TestCase):
csock.close()
ssock.close()
- @unittest.mock.patch('tulip.windows_utils.socket')
+ @unittest.mock.patch('asyncio.windows_utils.socket')
def test_winsocketpair_exc(self, m_socket):
m_socket.socket.return_value.getsockname.return_value = ('', 12345)
m_socket.socket.return_value.accept.return_value = object(), object()
diff --git a/update_stdlib.sh b/update_stdlib.sh
new file mode 100755
index 0000000..70e28f3
--- /dev/null
+++ b/update_stdlib.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# Script to copy asyncio files to the standard library tree.
+# Optional argument is the root of the Python 3.4 tree.
+# Assumes you have already created Lib/asyncio and
+# Lib/test/test_asyncio in the destination tree.
+
+CPYTHON=${1-$HOME/cpython}
+
+if [ ! -d $CPYTHON ]
+then
+ echo Bad destination $CPYTHON
+ exit 1
+fi
+
+if [ ! -f asyncio/__init__.py ]
+then
+ echo Bad current directory
+ exit 1
+fi
+
+maybe_copy()
+{
+ SRC=$1
+ DST=$CPYTHON/$2
+ if cmp $DST $SRC
+ then
+ return
+ fi
+ echo ======== $SRC === $DST ========
+ diff -u $DST $SRC
+ echo -n "Copy $SRC? [y/N] "
+ read X
+ case $X in
+ [yY]*) echo Copying $SRC; cp $SRC $DST;;
+ *) echo Not copying $SRC;;
+ esac
+}
+
+for i in `(cd asyncio && ls *.py)`
+do
+ if [ $i == selectors.py ]
+ then
+ continue
+ fi
+ maybe_copy asyncio/$i Lib/asyncio/$i
+done
+
+for i in `(cd tests && ls *.py sample.???)`
+do
+ maybe_copy tests/$i Lib/test/test_asyncio/$i
+done
+
+maybe_copy overlapped.c Modules/overlapped.c