Skip to content

Commit 5e0e39b

Browse files
committed
Improve coverage
1 parent 9a563d0 commit 5e0e39b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_toolsets.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,18 +690,26 @@ def get_inner_toolset(toolset: DynamicToolset[None] | None) -> EnterableToolset
690690
async with toolset:
691691
assert not toolset._toolset # pyright: ignore[reportPrivateUsage]
692692

693+
# Test that calling get_tools initializes the toolset
693694
tools = await toolset.get_tools(run_context)
694695

695696
assert (inner_toolset := get_inner_toolset(toolset))
696697
assert inner_toolset.depth_count == 1
697698

699+
# Test that the visitor applies when the toolset is initialized
698700
def visitor(toolset: AbstractToolset[None]) -> None:
699701
assert toolset is inner_toolset
700702

701703
toolset.apply(visitor)
702704

703705
assert get_inner_toolset(toolset) is None
704706

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+
705713
assert tools == {}
706714

707715

@@ -716,3 +724,12 @@ def no_toolset_func(ctx: RunContext[None]) -> None:
716724
tools = await toolset.get_tools(run_context)
717725

718726
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]

0 commit comments

Comments
 (0)