mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-134657: Remove newly added private names from asyncio.__all__ (#134665)
This commit is contained in:
parent
f1dcf3c7bf
commit
797abd1f7f
47 changed files with 105 additions and 90 deletions
|
@ -38,7 +38,7 @@ from test.support import threading_helper
|
|||
from test.support import ALWAYS_EQ, LARGEST, SMALLEST
|
||||
|
||||
def tearDownModule():
|
||||
asyncio._set_event_loop_policy(None)
|
||||
asyncio.events._set_event_loop_policy(None)
|
||||
|
||||
|
||||
def broken_unix_getsockname():
|
||||
|
@ -2843,13 +2843,13 @@ class PolicyTests(unittest.TestCase):
|
|||
self.assertIsInstance(policy, asyncio.DefaultEventLoopPolicy)
|
||||
|
||||
def test_event_loop_policy(self):
|
||||
policy = asyncio._AbstractEventLoopPolicy()
|
||||
policy = asyncio.events._AbstractEventLoopPolicy()
|
||||
self.assertRaises(NotImplementedError, policy.get_event_loop)
|
||||
self.assertRaises(NotImplementedError, policy.set_event_loop, object())
|
||||
self.assertRaises(NotImplementedError, policy.new_event_loop)
|
||||
|
||||
def test_get_event_loop(self):
|
||||
policy = asyncio._DefaultEventLoopPolicy()
|
||||
policy = test_utils.DefaultEventLoopPolicy()
|
||||
self.assertIsNone(policy._local._loop)
|
||||
|
||||
with self.assertRaises(RuntimeError):
|
||||
|
@ -2857,7 +2857,7 @@ class PolicyTests(unittest.TestCase):
|
|||
self.assertIsNone(policy._local._loop)
|
||||
|
||||
def test_get_event_loop_does_not_call_set_event_loop(self):
|
||||
policy = asyncio._DefaultEventLoopPolicy()
|
||||
policy = test_utils.DefaultEventLoopPolicy()
|
||||
|
||||
with mock.patch.object(
|
||||
policy, "set_event_loop",
|
||||
|
@ -2869,7 +2869,7 @@ class PolicyTests(unittest.TestCase):
|
|||
m_set_event_loop.assert_not_called()
|
||||
|
||||
def test_get_event_loop_after_set_none(self):
|
||||
policy = asyncio._DefaultEventLoopPolicy()
|
||||
policy = test_utils.DefaultEventLoopPolicy()
|
||||
policy.set_event_loop(None)
|
||||
self.assertRaises(RuntimeError, policy.get_event_loop)
|
||||
|
||||
|
@ -2877,7 +2877,7 @@ class PolicyTests(unittest.TestCase):
|
|||
def test_get_event_loop_thread(self, m_current_thread):
|
||||
|
||||
def f():
|
||||
policy = asyncio._DefaultEventLoopPolicy()
|
||||
policy = test_utils.DefaultEventLoopPolicy()
|
||||
self.assertRaises(RuntimeError, policy.get_event_loop)
|
||||
|
||||
th = threading.Thread(target=f)
|
||||
|
@ -2885,14 +2885,14 @@ class PolicyTests(unittest.TestCase):
|
|||
th.join()
|
||||
|
||||
def test_new_event_loop(self):
|
||||
policy = asyncio._DefaultEventLoopPolicy()
|
||||
policy = test_utils.DefaultEventLoopPolicy()
|
||||
|
||||
loop = policy.new_event_loop()
|
||||
self.assertIsInstance(loop, asyncio.AbstractEventLoop)
|
||||
loop.close()
|
||||
|
||||
def test_set_event_loop(self):
|
||||
policy = asyncio._DefaultEventLoopPolicy()
|
||||
policy = test_utils.DefaultEventLoopPolicy()
|
||||
old_loop = policy.new_event_loop()
|
||||
policy.set_event_loop(old_loop)
|
||||
|
||||
|
@ -2909,7 +2909,7 @@ class PolicyTests(unittest.TestCase):
|
|||
with self.assertWarnsRegex(
|
||||
DeprecationWarning, "'asyncio.get_event_loop_policy' is deprecated"):
|
||||
policy = asyncio.get_event_loop_policy()
|
||||
self.assertIsInstance(policy, asyncio._AbstractEventLoopPolicy)
|
||||
self.assertIsInstance(policy, asyncio.events._AbstractEventLoopPolicy)
|
||||
self.assertIs(policy, asyncio.get_event_loop_policy())
|
||||
|
||||
def test_set_event_loop_policy(self):
|
||||
|
@ -2922,7 +2922,7 @@ class PolicyTests(unittest.TestCase):
|
|||
DeprecationWarning, "'asyncio.get_event_loop_policy' is deprecated"):
|
||||
old_policy = asyncio.get_event_loop_policy()
|
||||
|
||||
policy = asyncio._DefaultEventLoopPolicy()
|
||||
policy = test_utils.DefaultEventLoopPolicy()
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning, "'asyncio.set_event_loop_policy' is deprecated"):
|
||||
asyncio.set_event_loop_policy(policy)
|
||||
|
@ -3034,13 +3034,13 @@ class GetEventLoopTestsMixin:
|
|||
class TestError(Exception):
|
||||
pass
|
||||
|
||||
class Policy(asyncio._DefaultEventLoopPolicy):
|
||||
class Policy(test_utils.DefaultEventLoopPolicy):
|
||||
def get_event_loop(self):
|
||||
raise TestError
|
||||
|
||||
old_policy = asyncio._get_event_loop_policy()
|
||||
old_policy = asyncio.events._get_event_loop_policy()
|
||||
try:
|
||||
asyncio._set_event_loop_policy(Policy())
|
||||
asyncio.events._set_event_loop_policy(Policy())
|
||||
loop = asyncio.new_event_loop()
|
||||
|
||||
with self.assertRaises(TestError):
|
||||
|
@ -3068,7 +3068,7 @@ class GetEventLoopTestsMixin:
|
|||
asyncio.get_event_loop()
|
||||
|
||||
finally:
|
||||
asyncio._set_event_loop_policy(old_policy)
|
||||
asyncio.events._set_event_loop_policy(old_policy)
|
||||
if loop is not None:
|
||||
loop.close()
|
||||
|
||||
|
@ -3078,9 +3078,9 @@ class GetEventLoopTestsMixin:
|
|||
self.assertIs(asyncio._get_running_loop(), None)
|
||||
|
||||
def test_get_event_loop_returns_running_loop2(self):
|
||||
old_policy = asyncio._get_event_loop_policy()
|
||||
old_policy = asyncio.events._get_event_loop_policy()
|
||||
try:
|
||||
asyncio._set_event_loop_policy(asyncio._DefaultEventLoopPolicy())
|
||||
asyncio.events._set_event_loop_policy(test_utils.DefaultEventLoopPolicy())
|
||||
loop = asyncio.new_event_loop()
|
||||
self.addCleanup(loop.close)
|
||||
|
||||
|
@ -3106,7 +3106,7 @@ class GetEventLoopTestsMixin:
|
|||
asyncio.get_event_loop()
|
||||
|
||||
finally:
|
||||
asyncio._set_event_loop_policy(old_policy)
|
||||
asyncio.events._set_event_loop_policy(old_policy)
|
||||
if loop is not None:
|
||||
loop.close()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue