我做了一个简单的测试用例:
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异常?
https://stackoverflow.com/questions/6103825
复制相似问题