File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -750,6 +750,10 @@ def test_future_cancelled_exception_refcycles(self):
750750 self .assertIsNotNone (exc )
751751 self .assertListEqual (gc .get_referrers (exc ), [])
752752
753+ def test_future_disallow_multiple_initialization (self ):
754+ f = self ._new_future (loop = self .loop )
755+ with self .assertRaises (RuntimeError , msg = "is already initialized" ):
756+ f .__init__ (loop = self .loop )
753757
754758@unittest .skipUnless (hasattr (futures , '_CFuture' ),
755759 'requires the C _asyncio module' )
Original file line number Diff line number Diff line change @@ -2776,6 +2776,18 @@ def test_get_context(self):
27762776 finally :
27772777 loop .close ()
27782778
2779+ def test_task_disallow_multiple_initialization (self ):
2780+ async def foo ():
2781+ pass
2782+
2783+ coro = foo ()
2784+ self .addCleanup (coro .close )
2785+ task = self .new_task (self .loop , coro )
2786+ task ._log_destroy_pending = False
2787+
2788+ with self .assertRaises (RuntimeError , msg = "is already initialized" ):
2789+ task .__init__ (coro , loop = self .loop )
2790+
27792791def add_subclass_tests (cls ):
27802792 BaseTask = cls .Task
27812793 BaseFuture = cls .Future
You can’t perform that action at this time.
0 commit comments