asyncio: Future.set_exception(exc) should instantiate exc if it is a class.

This commit is contained in:
Victor Stinner 2014-01-30 16:01:54 -08:00
parent 91445fbeb0
commit 9572898282
2 changed files with 7 additions and 0 deletions

View file

@ -79,6 +79,11 @@ class FutureTests(unittest.TestCase):
self.assertRaises(asyncio.InvalidStateError, f.set_exception, None)
self.assertFalse(f.cancel())
def test_exception_class(self):
f = asyncio.Future(loop=self.loop)
f.set_exception(RuntimeError)
self.assertIsInstance(f.exception(), RuntimeError)
def test_yield_from_twice(self):
f = asyncio.Future(loop=self.loop)