是否有与 `unittest.TestCase.fail()` 相反的方法来通过 Python 单元测试?

Is there an opposite methods to `unittest.TestCase.fail()` to pass a Python unit test?

我目前正在使用这个 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)

测试总是通过,以防没有失败的迹象。万一没事就什么都不做。