diff options
author | Victor Stinner <vstinner@redhat.com> | 2015-07-09 00:12:12 +0200 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2015-07-09 00:56:59 +0200 |
commit | 71046948a2ab96ae75b422db67dcc5ac1df8f0bf (patch) | |
tree | b5c212affa4f5ea68092260d23c4813300ad7a00 /tests | |
parent | 35906103b9f40df213cce2df48322f6106daa31e (diff) | |
download | trollius-git-71046948a2ab96ae75b422db67dcc5ac1df8f0bf.tar.gz |
Fix Python 3.4 issues
Diffstat (limited to 'tests')
-rw-r--r-- | tests/echo3.py | 3 | ||||
-rw-r--r-- | tests/test_asyncio.py | 2 | ||||
-rw-r--r-- | tests/test_locks.py | 4 | ||||
-rw-r--r-- | tests/test_subprocess.py | 1 | ||||
-rw-r--r-- | tests/test_tasks.py | 33 | ||||
-rw-r--r-- | tests/test_unix_events.py | 2 |
6 files changed, 8 insertions, 37 deletions
diff --git a/tests/echo3.py b/tests/echo3.py index 4c2b505..0644967 100644 --- a/tests/echo3.py +++ b/tests/echo3.py @@ -1,5 +1,4 @@ import os -from trollius.py33_exceptions import wrap_error if __name__ == '__main__': while True: @@ -7,6 +6,6 @@ if __name__ == '__main__': if not buf: break try: - wrap_error(os.write, 1, b'OUT:'+buf) + os.write(1, b'OUT:'+buf) except OSError as ex: os.write(2, b'ERR:' + ex.__class__.__name__.encode('ascii')) diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index 39d9e1a..d75054d 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -87,7 +87,7 @@ class AsyncioTests(test_utils.TestCase): fut = asyncio.Future() self.assertIs(fut._loop, self.loop) - fut2 = trollius.async(fut) + fut2 = trollius.ensure_future(fut) self.assertIs(fut2, fut) self.assertIs(fut._loop, self.loop) diff --git a/tests/test_locks.py b/tests/test_locks.py index ec7dbba..f3ea3b0 100644 --- a/tests/test_locks.py +++ b/tests/test_locks.py @@ -230,7 +230,7 @@ class LockTests(test_utils.TestCase): except RuntimeError as err: self.assertEqual( str(err), - '"yield" should be used as context manager expression') + '"yield From" should be used as context manager expression') self.assertFalse(lock.locked()) @@ -856,7 +856,7 @@ class SemaphoreTests(test_utils.TestCase): except RuntimeError as err: self.assertEqual( str(err), - '"yield" should be used as context manager expression') + '"yield From" should be used as context manager expression') self.assertEqual(2, sem._value) diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index 99071ee..b2eda3e 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -6,6 +6,7 @@ import signal import sys import unittest from trollius import From, Return +from trollius import base_subprocess from trollius import test_support as support from trollius.test_utils import mock from trollius.py33_exceptions import BrokenPipeError, ConnectionResetError diff --git a/tests/test_tasks.py b/tests/test_tasks.py index c2045a5..595b004 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -1,6 +1,7 @@ """Tests for tasks.py.""" import contextlib +import functools import os import re import sys @@ -356,6 +357,7 @@ class TaskTests(test_utils.TestCase): raise Return(12) t = asyncio.Task(task(), loop=loop) + test_utils.run_briefly(loop) loop.call_soon(t.cancel) with self.assertRaises(asyncio.CancelledError): loop.run_until_complete(t) @@ -1304,37 +1306,6 @@ class TaskTests(test_utils.TestCase): yield self.assertTrue(asyncio.iscoroutinefunction(fn2)) - def test_yield_vs_yield_from(self): - fut = asyncio.Future(loop=self.loop) - - @asyncio.coroutine - def wait_for_future(): - yield fut - - task = wait_for_future() - with self.assertRaises(RuntimeError): - self.loop.run_until_complete(task) - - self.assertFalse(fut.done()) - - def test_yield_vs_yield_from_generator(self): - @asyncio.coroutine - def coro(): - yield - - @asyncio.coroutine - def wait_for_future(): - gen = coro() - try: - yield gen - finally: - gen.close() - - task = wait_for_future() - self.assertRaises( - RuntimeError, - self.loop.run_until_complete, task) - def test_coroutine_non_gen_function(self): @asyncio.coroutine def func(): diff --git a/tests/test_unix_events.py b/tests/test_unix_events.py index 1223d86..698b130 100644 --- a/tests/test_unix_events.py +++ b/tests/test_unix_events.py @@ -1,7 +1,6 @@ """Tests for unix_events.py.""" import collections -import contextlib import errno import io import os @@ -282,6 +281,7 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase): # Ensure that the socket is closed on any bind error sock = mock.Mock() m_socket.socket.return_value = sock + m_socket.error = socket.error sock.bind.side_effect = OSError coro = self.loop.create_unix_server(lambda: None, path="/test") |