Use type match of expected error

immediate_remote_cancels
Tyler Goodlet 2021-10-15 10:07:45 -04:00
parent e4ed0fd2b3
commit 4f222a5f9c
1 changed files with 6 additions and 5 deletions

View File

@ -382,7 +382,7 @@ async def test_nested_multierrors(loglevel, start_method):
if subsub in (tractor.RemoteActorError,): if subsub in (tractor.RemoteActorError,):
subsub = subsub.type subsub = subsub.type
assert subsub in ( assert type(subsub) in (
trio.Cancelled, trio.Cancelled,
trio.MultiError, trio.MultiError,
) )
@ -394,13 +394,14 @@ async def test_nested_multierrors(loglevel, start_method):
# on windows sometimes spawning is just too slow and # on windows sometimes spawning is just too slow and
# we get back the (sent) cancel signal instead # we get back the (sent) cancel signal instead
if platform.system() == 'Windows': if platform.system() == 'Windows':
assert (subexc.type is trio.MultiError) or ( if isinstance(subexc, tractor.RemoteActorError):
subexc.type is tractor.RemoteActorError) assert subexc.type in (trio.MultiError, tractor.RemoteActorError)
else:
assert isinstance(subexc, trio.MultiError)
else: else:
assert subexc.type is trio.MultiError assert subexc.type is trio.MultiError
else: else:
assert (subexc.type is tractor.RemoteActorError) or ( assert subexc.type in (tractor.RemoteActorError, trio.Cancelled)
subexc.type is trio.Cancelled)
@no_windows @no_windows