[TIP] new assertion library for unit tests

Nicolas Chauvat nicolas.chauvat at logilab.fr
Wed Aug 13 01:48:14 PDT 2008

On Wed, Aug 13, 2008 at 05:50:43PM +1200, Michael Gratton wrote:
>   def testSplit(self):
>       s = 'foo,bar'
>       expected = ['foo', 'bar']
>       actual = s.split(',')
>       self.assertEqual(len(expected), len(actual),
>                        'Length of %s expected to equal %s' %
>                        (expected, len(actual)))
>       self.assertEqual(expected[0], actual[0])
>       self.assertEqual(expected[1], actual[1])

With logilab.common.testlib, that's

self.assertListEquals(expected, actual)

And you get a detailed error explaining what differs in case the lists
don't match.

Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances  

More information about the testing-in-python mailing list