[TIP] new assertion library for unit tests
Michael Foord
fuzzyman at voidspace.org.uk
Wed Aug 13 07:34:55 PDT 2008
Pete wrote:
> On Aug 13, 2008, at 3:48 AM, Nicolas Chauvat wrote:
>
>
>> 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.
>>
>
> Internally, I have an assert_sorted_equals function.
>
> But yeah, better list/dict/set test comparison funcs in unittest would
> be nice. Do I smell a PEP?
>
>
I'll probably do a PEP, given the unfortunate controversy over the last
proposed changes to unittest. I have a book to finish writing first that
will probably take another month.
Michael
> --Pete
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.resolverhacks.net/
http://www.theotherdelia.co.uk/
More information about the testing-in-python
mailing list