Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/build_st/python_tests/v1/st/test_v1_llm_utils.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-27 10:03 +0800

1#!/usr/bin/env python3 

2# -*- coding: utf-8 -*- 

3# ----------------------------------------------------------------------------------------------------------- 

4# Copyright (c) 2025 Huawei Technologies Co., Ltd. 

5# This program is free software, you can redistribute it and/or modify it under the terms and conditions of 

6# CANN Open Software License Agreement Version 2.0 (the "License"). 

7# Please refer to the License for details. You may not use this file except in compliance with the License. 

8# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 

9# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 

10# See LICENSE in the root of the software repository for the full text of the License. 

11# ----------------------------------------------------------------------------------------------------------- 

12 

13import unittest 

14 

15from llm_datadist_v1.llm_utils import ( 

16 layer_range_to_tensor_indices, 

17 parse_listen_ip_info, 

18) 

19 

20 

21class LlmUtilsSt(unittest.TestCase): 

22 def setUp(self): 

23 print("Begin ", self._testMethodName) 

24 

25 def tearDown(self): 

26 print("End ", self._testMethodName) 

27 

28 def testLayerRangeToTensorIndices(self): 

29 src_layer_range = range(1, 2) 

30 dst_layer_range = range(1, 2) 

31 result = layer_range_to_tensor_indices(src_layer_range, dst_layer_range) 

32 self.assertEqual(result[0], [2, 3]) 

33 self.assertEqual(result[1], [2, 3]) 

34 

35 def testParseListenIpInfo(self): 

36 listen_ip_info = "22:33" 

37 result = parse_listen_ip_info(listen_ip_info) 

38 self.assertEqual(result[0], "22") 

39 self.assertEqual(result[1], 33)