Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 216cc99

Browse filesBrowse files
Add a comment about clearing the policy.
1 parent b0519f9 commit 216cc99
Copy full SHA for 216cc99

File tree

Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed

‎Lib/test/test_concurrent_futures/test_interpreter_pool.py

Copy file name to clipboardExpand all lines: Lib/test/test_concurrent_futures/test_interpreter_pool.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,16 @@ class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase):
284284

285285
@classmethod
286286
def setUpClass(cls):
287+
# Most uses of asyncio will implicitly call set_event_loop_policy()
288+
# with the default policy if a policy hasn't been set already.
289+
# If that happens in a test, likw here, we'll end up with a failure
290+
# when --fail-env-changed is used. That's why the other tests that
291+
# use asyncio are careful to set the policy back to None and why
292+
# we're careful to do so here. We also validate that no other
293+
# tests left a policy in place, just in case.
287294
policy = support.maybe_get_event_loop_policy()
288295
assert policy is None, policy
289-
290-
@classmethod
291-
def tearDownClass(cls):
292-
asyncio.set_event_loop_policy(None)
296+
cls.addClassCleanup(lambda: asyncio.set_event_loop_policy(None))
293297

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.