Python unittest-多断言=>;don';如果其中至少有一个通过了,就不会失败

Python unittest-多断言=>;don';如果其中至少有一个通过了,就不会失败,python,unit-testing,python-unittest,Python,Unit Testing,Python Unittest,我现在正在这样做: try: self.assertIsNotNone(a) except AssertionError: try: self.assertIsTrue(b) except AssertionError: try: self.assertIn(c, C) except AssertionError: self.assertIsInstance(d, D) (这

我现在正在这样做:

try:
    self.assertIsNotNone(a)
except AssertionError:
    try:
        self.assertIsTrue(b)
    except AssertionError:
        try:
            self.assertIn(c, C)
        except AssertionError:
            self.assertIsInstance(d, D)
(这些断言中的任何一个都应该通过)

如何做得更好

--

更新:使用任何类型的断言

您可以使用:

self.assertFalse(any(x is None for x in (a, b, c, d)))

您可以执行
e=a或b或c或d
,然后执行
self.assertionsnotnone(e)