Coverage for cuda / core / experimental / _utils / clear_error_support.py: 75%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-10 01:19 +0000

1# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 

2# 

3# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE 

4 

5 

6def assert_type(obj, expected_type): 

7 """Ensure obj is of expected_type, else raise AssertionError with a clear message.""" 

8 if not isinstance(obj, expected_type): 

9 raise TypeError(f"Expected type {expected_type.__name__}, but got {type(obj).__name__}") 

10 

11 

12def assert_type_str_or_bytes_like(obj): 

13 """Ensure obj is of type str or bytes, else raise AssertionError with a clear message.""" 

14 if not isinstance(obj, (str, bytes, bytearray)): 

15 raise TypeError(f"Expected type str or bytes or bytearray, but got {type(obj).__name__}") 

16 

17 

18def raise_code_path_meant_to_be_unreachable(): 

19 raise RuntimeError("This code path is meant to be unreachable.")