Hi, On Thu, Dec 13, 2012 at 07:03:27AM -0800, Daniel Laird wrote: > I do am import unittest2 as unittest > The code does not fail but any use of the new functions results in: > NameError: global name 'assertListEqual' is not defined > > What am I doing wrong?
Read the error message again: it says that it cannot find the _global_ name 'assertListEqual'! assertListEqual is a method of unittest.TestCase. Hence, it has to be called on a unittest.TestCase instance, such as import unittest class FooTests(unittest.TestCase): def test_a_list(self): a = ['foo', 'bar'] b = ['foo', 'bar'] self.assertListEqual(a, b) BTW, I actually never used 'assertTypeEqual'. I rather call assertEqual and let unittest do the internals. I think assertEqual calls the right method for you depending on the arguments type. If you want to make sure that something is of a certain type use assertIsInstance! Hope this helps, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list