我做了一个简单的测试案例:
def setUp(self):
self.testListNone = None
def testListSlicing(self):
self.assertRaises(TypeError, self.testListNone[:1])
我希望能通过考试,但是我得到了例外:
Traceback (most recent call last):
self.assertRaises(TypeError, self.testListNone[:1])
TypeError: 'NoneType' object is unsubscriptable
我认为 assertRaises 将通过,因为 TypeError 异常将通过 被提高