diff options
author | Wulian <1055917385@qq.com> | 2024-08-11 16:35:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 16:35:51 (GMT) |
commit | bc9d92c67933917b474e61905451c6408c68e71d (patch) | |
tree | 3cbe6bee6f8d7029f26b7bdfdb5c57873088e073 /Lib/test | |
parent | 3aaed083a3f5eb7e490495c460b3dc1ce7451ce8 (diff) | |
download | cpython-bc9d92c67933917b474e61905451c6408c68e71d.zip cpython-bc9d92c67933917b474e61905451c6408c68e71d.tar.gz cpython-bc9d92c67933917b474e61905451c6408c68e71d.tar.bz2 |
gh-122858: Deprecate `asyncio.iscoroutinefunction` (#122875)
Deprecate `asyncio.iscoroutinefunction` in favor of `inspect.iscoroutinefunction`.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_pep492.py | 4 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 3 | ||||
-rw-r--r-- | Lib/test/test_unittest/testmock/testmagicmethods.py | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index 033784b..84c5f99 100644 --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -124,10 +124,10 @@ class CoroutineTests(BaseTest): self.assertFalse(asyncio.iscoroutine(foo())) - def test_iscoroutinefunction(self): async def foo(): pass - self.assertTrue(asyncio.iscoroutinefunction(foo)) + with self.assertWarns(DeprecationWarning): + self.assertTrue(asyncio.iscoroutinefunction(foo)) def test_async_def_coroutines(self): async def bar(): diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 9b22fb9..a1013ab 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -20,6 +20,7 @@ from asyncio import tasks from test.test_asyncio import utils as test_utils from test import support from test.support.script_helper import assert_python_ok +from test.support.warnings_helper import ignore_warnings def tearDownModule(): @@ -1939,6 +1940,7 @@ class BaseTaskTests: self.assertFalse(task.cancelled()) self.assertIs(task.exception(), base_exc) + @ignore_warnings(category=DeprecationWarning) def test_iscoroutinefunction(self): def fn(): pass @@ -1956,6 +1958,7 @@ class BaseTaskTests: self.assertFalse(asyncio.iscoroutinefunction(mock.Mock())) self.assertTrue(asyncio.iscoroutinefunction(mock.AsyncMock())) + @ignore_warnings(category=DeprecationWarning) def test_coroutine_non_gen_function(self): async def func(): return 'test' diff --git a/Lib/test/test_unittest/testmock/testmagicmethods.py b/Lib/test/test_unittest/testmock/testmagicmethods.py index a4feae7..5ca753b 100644 --- a/Lib/test/test_unittest/testmock/testmagicmethods.py +++ b/Lib/test/test_unittest/testmock/testmagicmethods.py @@ -1,7 +1,7 @@ import math import unittest import os -from asyncio import iscoroutinefunction +from inspect import iscoroutinefunction from unittest.mock import AsyncMock, Mock, MagicMock, _magics |