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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion 9 Lib/asyncio/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,19 @@ def get_function_source(func):


class TestCase(unittest.TestCase):
@staticmethod
def close_loop(loop):
executor = loop._default_executor
if executor is not None:
executor.shutdown(wait=True)
loop.close()

def set_event_loop(self, loop, *, cleanup=True):
assert loop is not None
# ensure that the event loop is passed explicitly in asyncio
events.set_event_loop(None)
if cleanup:
self.addCleanup(loop.close)
self.addCleanup(self.close_loop, loop)

def new_test_loop(self, gen=None):
loop = TestLoop(gen)
Expand Down
4 changes: 2 additions & 2 deletions 4 Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def tearDown(self):
if not self.loop.is_closed():
test_utils.run_briefly(self.loop)

self.loop.close()
gc.collect()
self.doCleanups()
support.gc_collect()
super().tearDown()

def test_run_until_complete_nesting(self):
Expand Down
2 changes: 2 additions & 0 deletions 2 Lib/test/test_asyncio/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def run(arg):
self.assertTrue(asyncio.isfuture(f2))
self.assertEqual(res, 'oi')
self.assertNotEqual(ident, threading.get_ident())
ex.shutdown(wait=True)

def test_wrap_future_future(self):
f1 = self._new_future(loop=self.loop)
Expand All @@ -428,6 +429,7 @@ def run(arg):
f1 = ex.submit(run, 'oi')
f2 = asyncio.wrap_future(f1)
self.assertIs(self.loop, f2._loop)
ex.shutdown(wait=True)

def test_wrap_future_cancel(self):
f1 = concurrent.futures.Future()
Expand Down
1 change: 0 additions & 1 deletion 1 Lib/test/test_asyncio/test_proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ def test_loop_self_reading_fut(self):
self.loop._loop_self_reading)

def test_loop_self_reading_exception(self):
self.loop.close = mock.Mock()
self.loop.call_exception_handler = mock.Mock()
self.proactor.recv.side_effect = OSError()
self.loop._loop_self_reading()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.