File tree 1 file changed +13
-0
lines changed
Lib/test/test_concurrent_futures
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,19 @@ def test_idle_thread_reuse(self):
282
282
283
283
class AsyncioTest (InterpretersMixin , testasyncio_utils .TestCase ):
284
284
285
+ @classmethod
286
+ 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, like 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.
294
+ policy = support .maybe_get_event_loop_policy ()
295
+ assert policy is None , policy
296
+ cls .addClassCleanup (lambda : asyncio .set_event_loop_policy (None ))
297
+
285
298
def setUp (self ):
286
299
super ().setUp ()
287
300
self .loop = asyncio .new_event_loop ()
You can’t perform that action at this time.
0 commit comments