Add a double started error checking test
parent
568902a5a9
commit
3f6099f161
|
@ -5,11 +5,39 @@ Verify the we raise errors when streams are opened prior to sync-opening
|
||||||
a ``tractor.Context`` beforehand.
|
a ``tractor.Context`` beforehand.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
import pytest
|
||||||
import trio
|
import trio
|
||||||
from trio.lowlevel import current_task
|
from trio.lowlevel import current_task
|
||||||
import tractor
|
import tractor
|
||||||
|
|
||||||
|
|
||||||
|
@tractor.context
|
||||||
|
async def really_started(
|
||||||
|
ctx: tractor.Context,
|
||||||
|
) -> None:
|
||||||
|
await ctx.started()
|
||||||
|
try:
|
||||||
|
await ctx.started()
|
||||||
|
except RuntimeError as err:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def test_started_called_more_then_once():
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
async with tractor.open_nursery() as n:
|
||||||
|
portal = await n.start_actor(
|
||||||
|
'too_much_starteds',
|
||||||
|
enable_modules=[__name__],
|
||||||
|
)
|
||||||
|
|
||||||
|
async with portal.open_context(really_started) as (ctx, sent):
|
||||||
|
pass
|
||||||
|
|
||||||
|
with pytest.raises(tractor.RemoteActorError) as excinfo:
|
||||||
|
trio.run(main)
|
||||||
|
|
||||||
|
|
||||||
@tractor.context
|
@tractor.context
|
||||||
async def never_open_stream(
|
async def never_open_stream(
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue