asyncio: New error handling API. Issue #20681.

This commit is contained in:
Yury Selivanov 2014-02-18 18:02:19 -05:00
parent 065efc3072
commit ff827f08ac
15 changed files with 491 additions and 99 deletions

View file

@ -174,20 +174,20 @@ class FutureTests(unittest.TestCase):
self.assertRaises(AssertionError, test)
fut.cancel()
@unittest.mock.patch('asyncio.futures.logger')
@unittest.mock.patch('asyncio.base_events.logger')
def test_tb_logger_abandoned(self, m_log):
fut = asyncio.Future(loop=self.loop)
del fut
self.assertFalse(m_log.error.called)
@unittest.mock.patch('asyncio.futures.logger')
@unittest.mock.patch('asyncio.base_events.logger')
def test_tb_logger_result_unretrieved(self, m_log):
fut = asyncio.Future(loop=self.loop)
fut.set_result(42)
del fut
self.assertFalse(m_log.error.called)
@unittest.mock.patch('asyncio.futures.logger')
@unittest.mock.patch('asyncio.base_events.logger')
def test_tb_logger_result_retrieved(self, m_log):
fut = asyncio.Future(loop=self.loop)
fut.set_result(42)
@ -195,7 +195,7 @@ class FutureTests(unittest.TestCase):
del fut
self.assertFalse(m_log.error.called)
@unittest.mock.patch('asyncio.futures.logger')
@unittest.mock.patch('asyncio.base_events.logger')
def test_tb_logger_exception_unretrieved(self, m_log):
fut = asyncio.Future(loop=self.loop)
fut.set_exception(RuntimeError('boom'))
@ -203,7 +203,7 @@ class FutureTests(unittest.TestCase):
test_utils.run_briefly(self.loop)
self.assertTrue(m_log.error.called)
@unittest.mock.patch('asyncio.futures.logger')
@unittest.mock.patch('asyncio.base_events.logger')
def test_tb_logger_exception_retrieved(self, m_log):
fut = asyncio.Future(loop=self.loop)
fut.set_exception(RuntimeError('boom'))
@ -211,7 +211,7 @@ class FutureTests(unittest.TestCase):
del fut
self.assertFalse(m_log.error.called)
@unittest.mock.patch('asyncio.futures.logger')
@unittest.mock.patch('asyncio.base_events.logger')
def test_tb_logger_exception_result_retrieved(self, m_log):
fut = asyncio.Future(loop=self.loop)
fut.set_exception(RuntimeError('boom'))