# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import pytest
from tests.tool_parsers.common_tests import (
ToolParserTestConfig,
ToolParserTests,
)
class TestQwen3xmlToolParser(ToolParserTests):
@pytest.fixture
def test_config(self) -> ToolParserTestConfig:
return ToolParserTestConfig(
parser_name="qwen3_xml",
# Test data
no_tool_calls_output="This is a regular response without any tool calls.",
single_tool_call_output="\n\nTokyo\n\n",
parallel_tool_calls_output="\n\nTokyo\n\n\n\nAsia/Tokyo\n\n",
various_data_types_output=(
"\n\n"
"hello\n"
"42\n"
"3.14\n"
"true\n"
"null\n"
'["a", "b", "c"]\n'
'{"nested": "value"}\n'
"\n"
),
empty_arguments_output="\n\n\n",
surrounding_text_output=(
"Let me check the weather for you.\n\n"
"\n\n"
"Tokyo\n"
"\n\n\n"
"I will get that information."
),
escaped_strings_output=(
"\n\n"
'He said "hello"\n'
"C:\\Users\\file.txt\n"
"line1\nline2\n"
"\n"
),
malformed_input_outputs=[
"",
"",
],
# Expected results
single_tool_call_expected_name="get_weather",
single_tool_call_expected_args={"city": "Tokyo"},
parallel_tool_calls_count=2,
parallel_tool_calls_names=["get_weather", "get_time"],
# xfail markers - Qwen3XML has systematic streaming issues
xfail_streaming={
"test_single_tool_call_simple_args": (
"Qwen3XML streaming has systematic issues"
),
"test_parallel_tool_calls": "Qwen3XML streaming has systematic issues",
"test_various_data_types": "Qwen3XML streaming has systematic issues",
"test_empty_arguments": "Qwen3XML streaming has systematic issues",
"test_surrounding_text": "Qwen3XML streaming has systematic issues",
"test_escaped_strings": "Qwen3XML streaming has systematic issues",
"test_malformed_input": (
"Qwen3XML parser is lenient with malformed input"
),
"test_streaming_reconstruction": (
"Qwen3XML streaming reconstruction has known issues"
),
},
supports_typed_arguments=False,
)