File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -690,18 +690,26 @@ def get_inner_toolset(toolset: DynamicToolset[None] | None) -> EnterableToolset
690
690
async with toolset :
691
691
assert not toolset ._toolset # pyright: ignore[reportPrivateUsage]
692
692
693
+ # Test that calling get_tools initializes the toolset
693
694
tools = await toolset .get_tools (run_context )
694
695
695
696
assert (inner_toolset := get_inner_toolset (toolset ))
696
697
assert inner_toolset .depth_count == 1
697
698
699
+ # Test that the visitor applies when the toolset is initialized
698
700
def visitor (toolset : AbstractToolset [None ]) -> None :
699
701
assert toolset is inner_toolset
700
702
701
703
toolset .apply (visitor )
702
704
703
705
assert get_inner_toolset (toolset ) is None
704
706
707
+ # Test that the visitor doesn't apply when the toolset is not initialized
708
+ def crash_visitor (toolset : AbstractToolset [None ]) -> None :
709
+ raise Exception ('crash' ) # pragma: no cover
710
+
711
+ assert toolset .apply (crash_visitor ) is None
712
+
705
713
assert tools == {}
706
714
707
715
@@ -716,3 +724,12 @@ def no_toolset_func(ctx: RunContext[None]) -> None:
716
724
tools = await toolset .get_tools (run_context )
717
725
718
726
assert tools == {}
727
+
728
+ async with toolset :
729
+ assert toolset ._toolset is None # pyright: ignore[reportPrivateUsage]
730
+
731
+ tools = await toolset .get_tools (run_context )
732
+
733
+ assert tools == {}
734
+
735
+ assert toolset ._toolset is None # pyright: ignore[reportPrivateUsage]
You can’t perform that action at this time.
0 commit comments