Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/build_ut/python_tests/v1/ut/test_v1_utils.py: 100%
23 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-27 10:02 +0800
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-27 10:02 +0800
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# -------------------------------------------------------------------
4# -----------------------------------------------------------------------------------------------------------
5# Copyright (c) 2025 Huawei Technologies Co., Ltd.
6# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
7# CANN Open Software License Agreement Version 2.0 (the "License").
8# Please refer to the License for details. You may not use this file except in compliance with the License.
9# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
10# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
11# See LICENSE in the root of the software repository for the full text of the License.
12# -----------------------------------------------------------------------------------------------------------
14# content of test_sample.py
15import ctypes
16import unittest
18from llm_datadist_v1.utils.utils import (
19 check_int32,
20 check_int64,
21 check_list_int32,
22 check_uint8,
23 check_uint16,
24 check_uint32,
25 check_uint64,
26)
29class TensorUt(unittest.TestCase):
30 def setUp(self) -> None:
31 print("Begin ", self._testMethodName)
33 def tearDown(self) -> None:
34 print("End ", self._testMethodName)
36 def test_check_exception(self):
37 with self.assertRaises(ValueError):
38 _ = check_uint64("cluster", -1)
39 with self.assertRaises(ValueError):
40 _ = check_int64("cluster", ctypes.c_uint64(2**64 - 1).value)
41 with self.assertRaises(ValueError):
42 _ = check_int32("cluster", ctypes.c_uint64(2**64 - 1).value)
43 with self.assertRaises(ValueError):
44 _ = check_uint32("cluster", -1)
45 with self.assertRaises(ValueError):
46 _ = check_list_int32("cluster_ids", [0, 1, ctypes.c_uint64(2**64 - 1).value])
47 with self.assertRaises(ValueError):
48 _ = check_uint16("cluster", -1)
49 with self.assertRaises(ValueError):
50 _ = check_uint8("cluster", -1)