diff options
author | Zac Medico <zmedico@gentoo.org> | 2021-01-18 03:49:28 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2021-01-18 03:50:10 -0800 |
commit | b7469f2f9777e818e9c0f3fa46e90c3f7f1c904a (patch) | |
tree | 72bf843d164598d7d0e5c9ea33787950fa7e2cb7 | |
parent | SimpleEmergeTestCase: Use async and await syntax (diff) | |
download | portage-b7469f2f9777e818e9c0f3fa46e90c3f7f1c904a.tar.gz portage-b7469f2f9777e818e9c0f3fa46e90c3f7f1c904a.tar.bz2 portage-b7469f2f9777e818e9c0f3fa46e90c3f7f1c904a.zip |
AsyncFunctionTestCase: Use async and await syntax
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r-- | lib/portage/tests/process/test_AsyncFunction.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/portage/tests/process/test_AsyncFunction.py b/lib/portage/tests/process/test_AsyncFunction.py index b3f80b8ac..ce4b2a93b 100644 --- a/lib/portage/tests/process/test_AsyncFunction.py +++ b/lib/portage/tests/process/test_AsyncFunction.py @@ -1,4 +1,4 @@ -# Copyright 2020 Gentoo Authors +# Copyright 2020-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import sys @@ -9,7 +9,6 @@ from portage.tests import TestCase from portage.util._async.AsyncFunction import AsyncFunction from portage.util.futures import asyncio from portage.util.futures._asyncio.streams import _writer -from portage.util.futures.compat_coroutine import coroutine from portage.util.futures.unix_events import _set_nonblocking @@ -20,8 +19,7 @@ class AsyncFunctionTestCase(TestCase): os.close(pw) return ''.join(sys.stdin) - @coroutine - def _testAsyncFunctionStdin(self, loop=None): + async def _testAsyncFunctionStdin(self, loop): test_string = '1\n2\n3\n' pr, pw = os.pipe() fd_pipes = {0:pr} @@ -30,8 +28,8 @@ class AsyncFunctionTestCase(TestCase): os.close(pr) _set_nonblocking(pw) with open(pw, mode='wb', buffering=0) as pipe_write: - yield _writer(pipe_write, test_string.encode('utf_8'), loop=loop) - self.assertEqual((yield reader.async_wait()), os.EX_OK) + await _writer(pipe_write, test_string.encode('utf_8')) + self.assertEqual((await reader.async_wait()), os.EX_OK) self.assertEqual(reader.result, test_string) def testAsyncFunctionStdin(self): |