2
2
import asyncio
3
3
import trio
4
4
import sniffio
5
- from async_generator import async_generator , yield_
6
5
from trio_asyncio import aio_as_trio , trio_as_aio
7
6
from tests import aiotest
8
7
from functools import partial
@@ -526,23 +525,21 @@ def err_asyncio():
526
525
527
526
@pytest .mark .trio
528
527
async def test_trio_asyncio_generator (self , loop ):
529
- @async_generator
530
528
async def dly_asyncio ():
531
- await yield_ ( 1 )
529
+ yield 1
532
530
await asyncio .sleep (0.01 , loop = loop )
533
- await yield_ ( 2 )
531
+ yield 2
534
532
535
533
with test_utils .deprecate (self ):
536
534
res = await async_gen_to_list (loop .wrap_generator (dly_asyncio ))
537
535
assert res == [1 , 2 ]
538
536
539
537
@pytest .mark .trio
540
538
async def test_trio_asyncio_generator_with_error (self , loop ):
541
- @async_generator
542
539
async def dly_asyncio ():
543
- await yield_ ( 1 )
540
+ yield 1
544
541
raise RuntimeError ("I has an owie" )
545
- await yield_ ( 2 )
542
+ yield 2
546
543
547
544
with test_utils .deprecate (self ):
548
545
with pytest .raises (RuntimeError ) as err :
@@ -551,9 +548,8 @@ async def dly_asyncio():
551
548
552
549
@pytest .mark .trio
553
550
async def test_trio_asyncio_generator_with_cancellation (self , loop ):
554
- @async_generator
555
551
async def dly_asyncio (hold , seen ):
556
- await yield_ ( 1 )
552
+ yield 1
557
553
seen .flag |= 1
558
554
await hold .wait ()
559
555
@@ -573,11 +569,10 @@ async def cancel_soon(nursery):
573
569
574
570
@pytest .mark .trio
575
571
async def test_trio_asyncio_iterator (self , loop ):
576
- @async_generator
577
572
async def slow_nums ():
578
573
for n in range (1 , 6 ):
579
574
await asyncio .sleep (0.01 , loop = loop )
580
- await yield_ ( n )
575
+ yield n
581
576
582
577
sum = 0
583
578
async for n in aio_as_trio (slow_nums ()):
@@ -586,11 +581,10 @@ async def slow_nums():
586
581
587
582
@pytest .mark .trio
588
583
async def test_trio_asyncio_iterator_depr (self , loop ):
589
- @async_generator
590
584
async def slow_nums ():
591
585
for n in range (1 , 6 ):
592
586
await asyncio .sleep (0.01 , loop = loop )
593
- await yield_ ( n )
587
+ yield n
594
588
595
589
sum = 0
596
590
# with test_utils.deprecate(self): ## not yet
0 commit comments