From 4f222a5f9c264d17ab632c718f805b276f30735a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 15 Oct 2021 10:07:45 -0400 Subject: [PATCH] Use type match of expected error --- tests/test_cancellation.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_cancellation.py b/tests/test_cancellation.py index 3c39956..a589f81 100644 --- a/tests/test_cancellation.py +++ b/tests/test_cancellation.py @@ -382,7 +382,7 @@ async def test_nested_multierrors(loglevel, start_method): if subsub in (tractor.RemoteActorError,): subsub = subsub.type - assert subsub in ( + assert type(subsub) in ( trio.Cancelled, trio.MultiError, ) @@ -394,13 +394,14 @@ async def test_nested_multierrors(loglevel, start_method): # on windows sometimes spawning is just too slow and # we get back the (sent) cancel signal instead if platform.system() == 'Windows': - assert (subexc.type is trio.MultiError) or ( - subexc.type is tractor.RemoteActorError) + if isinstance(subexc, tractor.RemoteActorError): + assert subexc.type in (trio.MultiError, tractor.RemoteActorError) + else: + assert isinstance(subexc, trio.MultiError) else: assert subexc.type is trio.MultiError else: - assert (subexc.type is tractor.RemoteActorError) or ( - subexc.type is trio.Cancelled) + assert subexc.type in (tractor.RemoteActorError, trio.Cancelled) @no_windows