mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-04-23 00:17:25 +08:00
6e416c62dd
* to_request_for_infer initial commit * refact to from_chat_completion_request * preprocess use request initial commit * bugfix * processors refact to using request * bug fix * refact Request from_generic_request * post process initial commit * bugfix * postprocess second commit * bugfix * serving_embedding initial commit * serving_reward initial commit * bugfix * replace function name * async_llm initial commit * offline initial commit and fix bug * bugfix * fix async_llm * remove add speculate_metrics into data * fix logprobs bug * fix echo bug * fix bug * fix reasoning_max_tokens * bugfix * bugfix and modify unittest * bugfix and modify unit test * bugfix * bugfix * bugfix * modify unittest * fix error when reasong_content is none for text_processor * remove some unnessary logic * revert removed logic * implement add and set method for RequestOutput and refact code * modify unit test * modify unit test * union process_request and process_request_obj * remove a unit test * union process_response and process_response_obj * support qwen3_vl_processor * modify unittest and remove comments * fix prompt_logprobs * fix codestyle * add v1 * v1 * fix unit test * fix unit test * fix pre-commit * fix * add process request * add process request * fix * fix * fix unit test * fix unit test * fix unit test * fix unit test * fix unit test * remove file * add unit test * add unit test * add unit test * fix unit test * fix unit test * fix * fix --------- Co-authored-by: Jiaxin Sui <95567040+plusNew001@users.noreply.github.com> Co-authored-by: luukunn <981429396@qq.com> Co-authored-by: luukunn <83932082+luukunn@users.noreply.github.com> Co-authored-by: Zhang Yulong <35552275+ZhangYulongg@users.noreply.github.com>
80 lines
3.2 KiB
Python
80 lines
3.2 KiB
Python
"""
|
|
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
"""
|
|
|
|
import unittest
|
|
from unittest.mock import mock_open, patch
|
|
|
|
import fastdeploy
|
|
from fastdeploy.utils import current_package_version, get_version_info
|
|
|
|
|
|
class TestVersion(unittest.TestCase):
|
|
def test_get_version(self):
|
|
ver = fastdeploy.version()
|
|
assert ver.count("COMMIT") > 0
|
|
|
|
@patch("builtins.open", new_callable=mock_open, read_data="fastdeploy version: 1.0.0\nother info")
|
|
def test_normal_version(self, mock_file):
|
|
"""测试正常版本号解析"""
|
|
self.assertEqual(current_package_version(), "1.0.0")
|
|
|
|
@patch("builtins.open", side_effect=FileNotFoundError)
|
|
def test_file_not_found(self, mock_file):
|
|
"""测试文件不存在的情况"""
|
|
self.assertEqual(current_package_version(), "Unknown")
|
|
|
|
@patch("builtins.open", new_callable=mock_open, read_data="some other content")
|
|
def test_no_version_line(self, mock_file):
|
|
"""测试找不到版本行的情况"""
|
|
self.assertEqual(current_package_version(), "Unknown")
|
|
|
|
@patch(
|
|
"builtins.open",
|
|
new_callable=mock_open,
|
|
read_data="""fastdeploy GIT COMMIT ID: 23d488c488779fdda73b427b49f6be40cf4408ba
|
|
Paddle version: 3.3.0.dev20251222
|
|
Paddle GIT COMMIT ID: f68bb752a51aacd333d74336e6ee62b7b3b21231
|
|
CUDA version: 12.6
|
|
CXX compiler version: 11.2.1
|
|
fastdeploy version: 2.4.0.dev20251223""",
|
|
)
|
|
def test_get_version_info(self, mock_file):
|
|
"""测试get_version_info函数"""
|
|
version_info = get_version_info()
|
|
self.assertIsNotNone(version_info)
|
|
self.assertEqual(version_info["fastdeploy_commit"], "23d488c488779fdda73b427b49f6be40cf4408ba")
|
|
self.assertEqual(version_info["paddle_version"], "3.3.0.dev20251222")
|
|
self.assertEqual(version_info["paddle_commit"], "f68bb752a51aacd333d74336e6ee62b7b3b21231")
|
|
self.assertEqual(version_info["cuda_version"], "12.6")
|
|
self.assertEqual(version_info["cxx_version"], "11.2.1")
|
|
self.assertEqual(version_info["fastdeploy_version"], "2.4.0.dev20251223")
|
|
|
|
@patch("builtins.open", side_effect=FileNotFoundError)
|
|
def test_get_version_info_file_not_found(self, mock_file):
|
|
"""测试get_version_info在文件不存在时返回None"""
|
|
version_info = get_version_info()
|
|
self.assertIsNone(version_info)
|
|
|
|
@patch("builtins.open", new_callable=mock_open, read_data="invalid content")
|
|
def test_get_version_info_empty_dict(self, mock_file):
|
|
"""测试get_version_info在内容无效时返回None"""
|
|
version_info = get_version_info()
|
|
self.assertIsNone(version_info)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|