Skip to content

Commit d5d8cc7

Browse files
committed
rework test
1 parent 4ee124c commit d5d8cc7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: src/py/reactpy/tests/test_core/test_hooks.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,11 @@ async def test_effect_external_cancellation_is_propagated():
594594
async def effect_func(e):
595595
async with e:
596596
did_start.set()
597-
asyncio.current_task().cancel()
598-
await asyncio.sleep(0) # allow cancellation to propagate
597+
# We don't use e.task or asyncio.current_task() because there seems to
598+
# be some platform dependence on whether the task is cancelled properly
599+
outer_task.cancel()
600+
# Allow cancellation to propagate
601+
await asyncio.sleep(0)
599602
did_cleanup.current = True
600603

601604
async def main():
@@ -604,7 +607,8 @@ async def main():
604607
await effect.stop()
605608

606609
with pytest.raises(asyncio.CancelledError):
607-
await main()
610+
outer_task = asyncio.create_task(main())
611+
await outer_task
608612

609613
assert not did_cleanup.current
610614

0 commit comments

Comments
 (0)