Unit testing beginner question

Andrius andrius.a at gmail.com
Mon May 23 18:30:59 EDT 2011


Hello,

would be gratefull for the explonation.

I did a simple test case:

def setUp(self):
  self.testListNone = None

def testListSlicing(self):
  self.assertRaises(TypeError, self.testListNone[:1])

and I am expecting test to pass, but I am getting exception:
Traceback (most recent call last):
    self.assertRaises(TypeError, self.testListNone[:1])
TypeError: 'NoneType' object is unsubscriptable

I thought that assertRaises will pass since TypeError exception will
be raised?

Ta,
Andrius






More information about the Python-list mailing list