assertEqual或assertNotEqual取决于条件

时间:2014-10-23 14:18:10

标签: python python-2.7 python-unittest

'我在单元测试中使用此功能:

def assertConditionally(a, b, condition):
    if condition:
        self.assertEqual(a, b)
    else:
        self.assertNotEqual(a, b)

还有其他办法吗?

1 个答案:

答案 0 :(得分:3)

self.assertEqual(a == b, condition)