File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 1+ import importlib .util
12import json
23import re
34from dataclasses import dataclass , replace
3536
3637from .conftest import IsDatetime , IsStr
3738
38- try :
39- import lark
40- except ImportError :
41- lark_installed = False
42- else :
43- lark_installed = True
44-
4539
4640def test_tool_no_ctx ():
4741 agent = Agent (TestModel ())
@@ -1489,14 +1483,14 @@ def test_function_text_format_regex_invalid():
14891483 FunctionTextFormat (syntax = 'regex' , grammar = '[' )
14901484
14911485
1492- @pytest .mark .skipif (not lark_installed , reason = 'lark not installed' )
1486+ @pytest .mark .skipif (not importlib . util . find_spec ( 'lark' ) , reason = 'lark not installed' )
14931487def test_function_text_format_lark_valid ():
14941488 format = FunctionTextFormat (syntax = 'lark' , grammar = 'start: "hello"' )
14951489 assert format .syntax == 'lark'
14961490 assert format .grammar == 'start: "hello"'
14971491
14981492
1499- @pytest .mark .skipif (not lark_installed , reason = 'lark not installed' )
1493+ @pytest .mark .skipif (not importlib . util . find_spec ( 'lark' ) , reason = 'lark not installed' )
15001494def test_function_text_format_lark_invalid ():
15011495 with pytest .raises (ValueError , match = 'Lark grammar is invalid' ):
15021496 FunctionTextFormat (syntax = 'lark' , grammar = 'invalid grammar [' )
You can’t perform that action at this time.
0 commit comments