FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-93896: allow enabling asyncio.Runner calls to asyncio.set_event_loop independantly to loop_factory by graingert · Pull Request #94058 · python/cpython · GitHub

Repository navigation

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
test that asyncio.Runner does not touch the asyncio policy system
  • Loading branch information
graingert committed Jun 22, 2022
commit 7786b44539480337c6832917943229b8a298c3a4
21 changes: 20 additions & 1 deletion Lib/test/test_asyncio/test_runners.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ def set_event_loop(self, loop):
self.loop = loop


class NullPolicy(asyncio.AbstractEventLoopPolicy):

def get_event_loop(self):
# shouldn't ever be called by asyncio.run()
raise RuntimeError

def new_event_loop(self):
raise RuntimeError

def set_event_loop(self, loop):
raise RuntimeError


class BaseTest(unittest.TestCase):

def new_loop(self):
Expand All @@ -60,7 +73,7 @@ async def shutdown_asyncgens():
def setUp(self):
super().setUp()

policy = TestPolicy(self.new_loop)
policy = NullPolicy()
asyncio.set_event_loop_policy(policy)

def tearDown(self):
Expand All @@ -75,6 +88,12 @@ def tearDown(self):

class RunTests(BaseTest):

def setUp(self):
super().setUp()

policy = TestPolicy(self.new_loop)
asyncio.set_event_loop_policy(policy)

def test_asyncio_run_return(self):
async def main():
await asyncio.sleep(0)
Expand Down

Back | FazBrowse Home | New Git URL