File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -570,14 +570,19 @@ def block_for_close(
570570 ------
571571 BentoError
572572 If the connection is terminated unexpectedly.
573+ ValueError
574+ If the client has never connected.
573575
574576 See Also
575577 --------
576578 wait_for_close
577579
578580 """
581+ if self ._connection is None :
582+ raise ValueError ("cannot block_for_close before connecting" )
583+
579584 if not self .is_connected ():
580- raise ValueError ( "cannot wait for close before connecting" )
585+ return
581586
582587 try :
583588 asyncio .run_coroutine_threadsafe (
@@ -612,14 +617,19 @@ async def wait_for_close(
612617 ------
613618 BentoError
614619 If the connection is terminated unexpectedly.
620+ ValueError
621+ If the client has never connected.
615622
616623 See Also
617624 --------
618625 block_for_close
619626
620627 """
628+ if self ._connection is None :
629+ raise ValueError ("cannot wait_for_close before connecting" )
630+
621631 if not self .is_connected ():
622- raise ValueError ( "cannot wait for close before connecting" )
632+ return
623633
624634 waiter = asyncio .wrap_future (
625635 asyncio .run_coroutine_threadsafe (
Original file line number Diff line number Diff line change @@ -436,6 +436,17 @@ def test_live_block_for_close_timeout(
436436 live_client .terminate .assert_called_once () # type: ignore
437437
438438
439+ def test_live_block_for_close_dry (
440+ live_client : client .Live ,
441+ ) -> None :
442+ """
443+ Test that block_for_close raises a ValueError if the client
444+ has never connected.
445+ """
446+ with pytest .raises (ValueError ):
447+ live_client .block_for_close ()
448+
449+
439450@pytest .mark .asyncio
440451@pytest .mark .usefixtures ("mock_live_server" )
441452async def test_live_wait_for_close (
@@ -460,6 +471,18 @@ async def test_live_wait_for_close(
460471 assert not live_client .is_connected ()
461472
462473
474+ @pytest .mark .asyncio
475+ async def test_live_wait_for_close_dry (
476+ live_client : client .Live ,
477+ ) -> None :
478+ """
479+ Test that wait_for_close raises a ValueError if the client
480+ has never connected.
481+ """
482+ with pytest .raises (ValueError ):
483+ await live_client .wait_for_close ()
484+
485+
463486@pytest .mark .asyncio
464487@pytest .mark .usefixtures ("mock_live_server" )
465488async def test_live_wait_for_close_timeout (
You can’t perform that action at this time.
0 commit comments