mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
fixed failed tests due to RaisesGroup
This commit is contained in:
committed by
Paul Robinson
parent
0be78be06a
commit
7495039a29
@ -67,7 +67,7 @@ async def test_single_protocol_fails(security_protocol):
|
||||
|
||||
# the StreamFailure is within 2 nested ExceptionGroups, so we use strict=False
|
||||
# to unwrap down to the core Exception
|
||||
with RaisesGroup(StreamFailure, strict=False):
|
||||
with RaisesGroup(StreamFailure, allow_unwrapped=True, flatten_subgroups=True):
|
||||
await perform_simple_test(
|
||||
"", [PROTOCOL_ECHO], [PROTOCOL_POTATO], security_protocol
|
||||
)
|
||||
@ -112,7 +112,7 @@ async def test_multiple_protocol_fails(security_protocol):
|
||||
|
||||
# the StreamFailure is within 2 nested ExceptionGroups, so we use strict=False
|
||||
# to unwrap down to the core Exception
|
||||
with RaisesGroup(StreamFailure, strict=False):
|
||||
with RaisesGroup(StreamFailure, allow_unwrapped=True, flatten_subgroups=True):
|
||||
await perform_simple_test(
|
||||
"", protocols_for_client, protocols_for_listener, security_protocol
|
||||
)
|
||||
|
||||
@ -135,7 +135,9 @@ async def test_trio_service_lifecycle_run_and_exception():
|
||||
|
||||
async def do_service_run():
|
||||
with RaisesGroup(
|
||||
Matcher(RuntimeError, match="Service throwing error"), strict=False
|
||||
Matcher(RuntimeError, match="Service throwing error"),
|
||||
allow_unwrapped=True,
|
||||
flatten_subgroups=True,
|
||||
):
|
||||
await manager.run()
|
||||
|
||||
@ -164,7 +166,9 @@ async def test_trio_service_lifecycle_run_and_task_exception():
|
||||
|
||||
async def do_service_run():
|
||||
with RaisesGroup(
|
||||
Matcher(RuntimeError, match="Service throwing error"), strict=False
|
||||
Matcher(RuntimeError, match="Service throwing error"),
|
||||
allow_unwrapped=True,
|
||||
flatten_subgroups=True,
|
||||
):
|
||||
await manager.run()
|
||||
|
||||
@ -226,7 +230,11 @@ async def test_trio_service_lifecycle_run_and_daemon_task_exit():
|
||||
manager = TrioManager(service)
|
||||
|
||||
async def do_service_run():
|
||||
with RaisesGroup(Matcher(DaemonTaskExit, match="Daemon task"), strict=False):
|
||||
with RaisesGroup(
|
||||
Matcher(DaemonTaskExit, match="Daemon task"),
|
||||
allow_unwrapped=True,
|
||||
flatten_subgroups=True,
|
||||
):
|
||||
await manager.run()
|
||||
|
||||
await do_service_lifecycle_check(
|
||||
@ -388,7 +396,9 @@ async def test_trio_service_manager_run_task_reraises_exceptions():
|
||||
await trio.sleep_forever()
|
||||
|
||||
with RaisesGroup(
|
||||
Matcher(Exception, match="task exception in run_task"), strict=False
|
||||
Matcher(Exception, match="task exception in run_task"),
|
||||
allow_unwrapped=True,
|
||||
flatten_subgroups=True,
|
||||
):
|
||||
async with background_trio_service(RunTaskService()):
|
||||
task_event.set()
|
||||
@ -413,7 +423,8 @@ async def test_trio_service_manager_run_daemon_task_cancels_if_exits():
|
||||
Matcher(
|
||||
DaemonTaskExit, match=r"Daemon task daemon_task_fn\[daemon=True\] exited"
|
||||
),
|
||||
strict=False,
|
||||
allow_unwrapped=True,
|
||||
flatten_subgroups=True,
|
||||
):
|
||||
async with background_trio_service(RunTaskService()):
|
||||
task_event.set()
|
||||
@ -432,7 +443,11 @@ async def test_trio_service_manager_propogates_and_records_exceptions():
|
||||
|
||||
assert manager.did_error is False
|
||||
|
||||
with RaisesGroup(Matcher(RuntimeError, match="this is the error"), strict=False):
|
||||
with RaisesGroup(
|
||||
Matcher(RuntimeError, match="this is the error"),
|
||||
allow_unwrapped=True,
|
||||
flatten_subgroups=True,
|
||||
):
|
||||
await manager.run()
|
||||
|
||||
assert manager.did_error is True
|
||||
@ -645,7 +660,7 @@ async def test_error_in_service_run():
|
||||
self.manager.run_daemon_task(self.manager.wait_finished)
|
||||
raise ValueError("Exception inside run()")
|
||||
|
||||
with RaisesGroup(ValueError, strict=False):
|
||||
with RaisesGroup(ValueError, allow_unwrapped=True, flatten_subgroups=True):
|
||||
await TrioManager.run_service(ServiceTest())
|
||||
|
||||
|
||||
@ -664,5 +679,5 @@ async def test_daemon_task_finishes_leaving_children():
|
||||
async def run(self):
|
||||
self.manager.run_daemon_task(self.buggy_daemon)
|
||||
|
||||
with RaisesGroup(DaemonTaskExit, strict=False):
|
||||
with RaisesGroup(DaemonTaskExit, allow_unwrapped=True, flatten_subgroups=True):
|
||||
await TrioManager.run_service(ServiceTest())
|
||||
|
||||
@ -50,7 +50,7 @@ async def test_trio_service_external_api_raises_when_cancelled():
|
||||
service = ExternalAPIService()
|
||||
|
||||
async with background_trio_service(service) as manager:
|
||||
with RaisesGroup(LifecycleError, strict=False):
|
||||
with RaisesGroup(LifecycleError, allow_unwrapped=True, flatten_subgroups=True):
|
||||
async with trio.open_nursery() as nursery:
|
||||
# an event to ensure that we are indeed within the body of the
|
||||
is_within_fn = trio.Event()
|
||||
|
||||
Reference in New Issue
Block a user