已合并
test update ut #39948
huangyunlong创建于 7月3日
test update ut #39948
已合并
huangyunlong创建于 7月3日
1 个文件变更+10-12
@@ -7,8 +7,6 @@ from functools import wraps
7import torch7import torch
8import torch_npu8import torch_npu
9 9 
10-import torch_npu.npu.utils as utils
11- 
12from torch_npu.testing.testcase import TestCase, run_tests10from torch_npu.testing.testcase import TestCase, run_tests
13from torch_npu.testing.common_utils import SupportedDevices, SkipIfNotGteCANNVersion11from torch_npu.testing.common_utils import SupportedDevices, SkipIfNotGteCANNVersion
14 12 
@@ -114,6 +112,16 @@ class TestAclOpInitMode(TestCase):
114 self.assertIn(self.INVALID_VALUE_WARN, stderr)112 self.assertIn(self.INVALID_VALUE_WARN, stderr)
115 113 
116 114 
115+def _skipIfLazy(fn):
116+ @wraps(fn)
117+ def wrapper(slf, *args, **kwargs):
118+ if torch_npu.npu.utils._is_gte_cann_version('8.3.RC1'):
119+ raise unittest.SkipTest(
120+ "Test only for non-lazy set_device mode (CANN < 8.3.RC1)")
121+ return fn(slf, *args, **kwargs)
122+ return wrapper
123+ 
124+ 
117class TestAclInitConfigPath(TestCase):125class TestAclInitConfigPath(TestCase):
118 126 
119 LACKS_DEFAULT_DEVICE_MSG = "lacks 'defaultDevice'"127 LACKS_DEFAULT_DEVICE_MSG = "lacks 'defaultDevice'"
@@ -170,16 +178,6 @@ class TestAclInitConfigPath(TestCase):
170 178 
171 # ---- non-lazy 模式(CANN < 8.3.RC1) ----179 # ---- non-lazy 模式(CANN < 8.3.RC1) ----
172 180 
173- @staticmethod
174- def _skipIfLazy(fn):
175- @wraps(fn)
176- def wrapper(slf, *args, **kwargs):
177- if utils._is_gte_cann_version('8.3.RC1'):
178- raise unittest.SkipTest(
179- "Test only for non-lazy set_device mode (CANN < 8.3.RC1)")
180- return fn(slf, *args, **kwargs)
181- return wrapper
182- 
183 @_skipIfLazy181 @_skipIfLazy
184 def test_valid_json_non_lazy(self):182 def test_valid_json_non_lazy(self):
185 """non-lazy 模式:不含 defaultDevice 的用户 JSON 正常使用"""183 """non-lazy 模式:不含 defaultDevice 的用户 JSON 正常使用"""