Adjust all `RemoteActorError.type` using tests
To instead use the new `.boxed_type` B)mv_to_new_trio_py3.11
parent
78434f6317
commit
9221c57234
|
@ -32,7 +32,7 @@ async def main():
|
|||
try:
|
||||
await p1.run(name_error)
|
||||
except tractor.RemoteActorError as rae:
|
||||
assert rae.type is NameError
|
||||
assert rae.boxed_type is NameError
|
||||
|
||||
async for i in stream:
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ def test_remote_error(reg_addr, args_err):
|
|||
# of this actor nursery.
|
||||
await portal.result()
|
||||
except tractor.RemoteActorError as err:
|
||||
assert err.type == errtype
|
||||
assert err.boxed_type == errtype
|
||||
print("Look Maa that actor failed hard, hehh")
|
||||
raise
|
||||
|
||||
|
@ -86,7 +86,7 @@ def test_remote_error(reg_addr, args_err):
|
|||
with pytest.raises(tractor.RemoteActorError) as excinfo:
|
||||
trio.run(main)
|
||||
|
||||
assert excinfo.value.type == errtype
|
||||
assert excinfo.value.boxed_type == errtype
|
||||
|
||||
else:
|
||||
# the root task will also error on the `.result()` call
|
||||
|
@ -96,7 +96,7 @@ def test_remote_error(reg_addr, args_err):
|
|||
|
||||
# ensure boxed errors
|
||||
for exc in excinfo.value.exceptions:
|
||||
assert exc.type == errtype
|
||||
assert exc.boxed_type == errtype
|
||||
|
||||
|
||||
def test_multierror(reg_addr):
|
||||
|
@ -117,7 +117,7 @@ def test_multierror(reg_addr):
|
|||
try:
|
||||
await portal2.result()
|
||||
except tractor.RemoteActorError as err:
|
||||
assert err.type == AssertionError
|
||||
assert err.boxed_type == AssertionError
|
||||
print("Look Maa that first actor failed hard, hehh")
|
||||
raise
|
||||
|
||||
|
@ -169,7 +169,7 @@ def test_multierror_fast_nursery(reg_addr, start_method, num_subactors, delay):
|
|||
|
||||
for exc in exceptions:
|
||||
assert isinstance(exc, tractor.RemoteActorError)
|
||||
assert exc.type == AssertionError
|
||||
assert exc.boxed_type == AssertionError
|
||||
|
||||
|
||||
async def do_nothing():
|
||||
|
@ -310,7 +310,7 @@ async def test_some_cancels_all(num_actors_and_errs, start_method, loglevel):
|
|||
await portal.run(func, **kwargs)
|
||||
|
||||
except tractor.RemoteActorError as err:
|
||||
assert err.type == err_type
|
||||
assert err.boxed_type == err_type
|
||||
# we only expect this first error to propogate
|
||||
# (all other daemons are cancelled before they
|
||||
# can be scheduled)
|
||||
|
@ -329,11 +329,11 @@ async def test_some_cancels_all(num_actors_and_errs, start_method, loglevel):
|
|||
assert len(err.exceptions) == num_actors
|
||||
for exc in err.exceptions:
|
||||
if isinstance(exc, tractor.RemoteActorError):
|
||||
assert exc.type == err_type
|
||||
assert exc.boxed_type == err_type
|
||||
else:
|
||||
assert isinstance(exc, trio.Cancelled)
|
||||
elif isinstance(err, tractor.RemoteActorError):
|
||||
assert err.type == err_type
|
||||
assert err.boxed_type == err_type
|
||||
|
||||
assert n.cancelled is True
|
||||
assert not n._children
|
||||
|
@ -412,7 +412,7 @@ async def test_nested_multierrors(loglevel, start_method):
|
|||
elif isinstance(subexc, tractor.RemoteActorError):
|
||||
# on windows it seems we can't exactly be sure wtf
|
||||
# will happen..
|
||||
assert subexc.type in (
|
||||
assert subexc.boxed_type in (
|
||||
tractor.RemoteActorError,
|
||||
trio.Cancelled,
|
||||
BaseExceptionGroup,
|
||||
|
@ -422,7 +422,7 @@ async def test_nested_multierrors(loglevel, start_method):
|
|||
for subsub in subexc.exceptions:
|
||||
|
||||
if subsub in (tractor.RemoteActorError,):
|
||||
subsub = subsub.type
|
||||
subsub = subsub.boxed_type
|
||||
|
||||
assert type(subsub) in (
|
||||
trio.Cancelled,
|
||||
|
@ -437,16 +437,16 @@ async def test_nested_multierrors(loglevel, start_method):
|
|||
# we get back the (sent) cancel signal instead
|
||||
if is_win():
|
||||
if isinstance(subexc, tractor.RemoteActorError):
|
||||
assert subexc.type in (
|
||||
assert subexc.boxed_type in (
|
||||
BaseExceptionGroup,
|
||||
tractor.RemoteActorError
|
||||
)
|
||||
else:
|
||||
assert isinstance(subexc, BaseExceptionGroup)
|
||||
else:
|
||||
assert subexc.type is ExceptionGroup
|
||||
assert subexc.boxed_type is ExceptionGroup
|
||||
else:
|
||||
assert subexc.type in (
|
||||
assert subexc.boxed_type in (
|
||||
tractor.RemoteActorError,
|
||||
trio.Cancelled
|
||||
)
|
||||
|
|
|
@ -171,4 +171,4 @@ def test_actor_managed_trio_nursery_task_error_cancels_aio(
|
|||
|
||||
# verify boxed error
|
||||
err = excinfo.value
|
||||
assert isinstance(err.type(), NameError)
|
||||
assert err.boxed_type is NameError
|
||||
|
|
|
@ -795,7 +795,7 @@ async def test_callee_cancels_before_started(
|
|||
|
||||
# raises a special cancel signal
|
||||
except tractor.ContextCancelled as ce:
|
||||
ce.type == trio.Cancelled
|
||||
ce.boxed_type == trio.Cancelled
|
||||
|
||||
# the traceback should be informative
|
||||
assert 'itself' in ce.msgdata['tb_str']
|
||||
|
@ -903,7 +903,7 @@ def test_one_end_stream_not_opened(
|
|||
with pytest.raises(tractor.RemoteActorError) as excinfo:
|
||||
trio.run(main)
|
||||
|
||||
assert excinfo.value.type == StreamOverrun
|
||||
assert excinfo.value.boxed_type == StreamOverrun
|
||||
|
||||
elif overrunner == 'callee':
|
||||
with pytest.raises(tractor.RemoteActorError) as excinfo:
|
||||
|
@ -912,7 +912,7 @@ def test_one_end_stream_not_opened(
|
|||
# TODO: embedded remote errors so that we can verify the source
|
||||
# error? the callee delivers an error which is an overrun
|
||||
# wrapped in a remote actor error.
|
||||
assert excinfo.value.type == tractor.RemoteActorError
|
||||
assert excinfo.value.boxed_type == tractor.RemoteActorError
|
||||
|
||||
else:
|
||||
trio.run(main)
|
||||
|
@ -1131,7 +1131,7 @@ def test_maybe_allow_overruns_stream(
|
|||
# NOTE: i tried to isolate to a deterministic case here
|
||||
# based on timeing, but i was kinda wasted, and i don't
|
||||
# think it's sane to catch them..
|
||||
assert err.type in (
|
||||
assert err.boxed_type in (
|
||||
tractor.RemoteActorError,
|
||||
StreamOverrun,
|
||||
)
|
||||
|
@ -1139,10 +1139,10 @@ def test_maybe_allow_overruns_stream(
|
|||
elif (
|
||||
slow_side == 'child'
|
||||
):
|
||||
assert err.type == StreamOverrun
|
||||
assert err.boxed_type == StreamOverrun
|
||||
|
||||
elif slow_side == 'parent':
|
||||
assert err.type == tractor.RemoteActorError
|
||||
assert err.boxed_type == tractor.RemoteActorError
|
||||
assert 'StreamOverrun' in err.msgdata['tb_str']
|
||||
|
||||
else:
|
||||
|
|
|
@ -128,7 +128,7 @@ def test_aio_simple_error(reg_addr):
|
|||
assert err
|
||||
|
||||
assert isinstance(err, RemoteActorError)
|
||||
assert err.type == AssertionError
|
||||
assert err.boxed_type == AssertionError
|
||||
|
||||
|
||||
def test_tractor_cancels_aio(reg_addr):
|
||||
|
@ -272,7 +272,7 @@ def test_context_spawns_aio_task_that_errors(
|
|||
|
||||
err = excinfo.value
|
||||
assert isinstance(err, expect)
|
||||
assert err.type == AssertionError
|
||||
assert err.boxed_type == AssertionError
|
||||
|
||||
|
||||
async def aio_cancel():
|
||||
|
@ -314,7 +314,7 @@ def test_aio_cancelled_from_aio_causes_trio_cancelled(reg_addr):
|
|||
assert err
|
||||
|
||||
# ensure boxed error is correct
|
||||
assert err.type == to_asyncio.AsyncioCancelled
|
||||
assert err.boxed_type == to_asyncio.AsyncioCancelled
|
||||
|
||||
|
||||
# TODO: verify open_channel_from will fail on this..
|
||||
|
@ -466,7 +466,7 @@ def test_trio_error_cancels_intertask_chan(reg_addr):
|
|||
|
||||
# ensure boxed errors
|
||||
for exc in excinfo.value.exceptions:
|
||||
assert exc.type == Exception
|
||||
assert exc.boxed_type == Exception
|
||||
|
||||
|
||||
def test_trio_closes_early_and_channel_exits(reg_addr):
|
||||
|
@ -500,7 +500,7 @@ def test_aio_errors_and_channel_propagates_and_closes(reg_addr):
|
|||
|
||||
# ensure boxed errors
|
||||
for exc in excinfo.value.exceptions:
|
||||
assert exc.type == Exception
|
||||
assert exc.boxed_type == Exception
|
||||
|
||||
|
||||
@tractor.context
|
||||
|
|
|
@ -36,7 +36,7 @@ async def sleep_back_actor(
|
|||
if not exposed_mods:
|
||||
expect = tractor.ModuleNotExposed
|
||||
|
||||
assert err.type is expect
|
||||
assert err.boxed_type is expect
|
||||
raise
|
||||
else:
|
||||
await trio.sleep(float('inf'))
|
||||
|
@ -150,4 +150,4 @@ def test_rpc_errors(
|
|||
))
|
||||
|
||||
if getattr(value, 'type', None):
|
||||
assert value.type is inside_err
|
||||
assert value.boxed_type is inside_err
|
||||
|
|
Loading…
Reference in New Issue