not*_*eek 5 python warnings unit-testing python-unittest
我目前正在使用它self.assertTrue(True)来通过测试。我想要的是如果出现特定警告则通过测试。
import warnings
class test(unittest.TestCase):
def test_1(self):
with warning.catch_warnings(record=False):
warning.simplefilter("error", category=CustomWarning)
try: function_that_raisesCustomWarning()
except CustomWarning as w: self.assertTrue(True)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1075 次 |
| 最近记录: |