mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
gh-127949: deprecate asyncio policy classes (#128216)
This commit is contained in:
parent
3f6a618e49
commit
a391d80f4b
8 changed files with 82 additions and 34 deletions
|
@ -328,14 +328,15 @@ class WinPolicyTests(WindowsEventsTestCase):
|
|||
|
||||
def test_selector_win_policy(self):
|
||||
async def main():
|
||||
self.assertIsInstance(
|
||||
asyncio.get_running_loop(),
|
||||
asyncio.SelectorEventLoop)
|
||||
self.assertIsInstance(asyncio.get_running_loop(), asyncio.SelectorEventLoop)
|
||||
|
||||
old_policy = asyncio._get_event_loop_policy()
|
||||
try:
|
||||
asyncio._set_event_loop_policy(
|
||||
asyncio.WindowsSelectorEventLoopPolicy())
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"'asyncio.WindowsSelectorEventLoopPolicy' is deprecated",
|
||||
):
|
||||
asyncio._set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||
asyncio.run(main())
|
||||
finally:
|
||||
asyncio._set_event_loop_policy(old_policy)
|
||||
|
@ -348,8 +349,11 @@ class WinPolicyTests(WindowsEventsTestCase):
|
|||
|
||||
old_policy = asyncio._get_event_loop_policy()
|
||||
try:
|
||||
asyncio._set_event_loop_policy(
|
||||
asyncio.WindowsProactorEventLoopPolicy())
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"'asyncio.WindowsProactorEventLoopPolicy' is deprecated",
|
||||
):
|
||||
asyncio._set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
|
||||
asyncio.run(main())
|
||||
finally:
|
||||
asyncio._set_event_loop_policy(old_policy)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue