unittest weirdness
Terry Reedy
tjreedy at udel.edu
Tue Mar 11 23:36:44 EDT 2014
On 3/11/2014 6:13 PM, John Gordon wrote:
> In <mailman.8062.1394573210.18130.python-list at python.org> Ethan Furman <ethan at stoneleaf.us> writes:
>
>> if missing:
>> raise ValueError('invoices %r missing from batch' % missing)
>
> It's been a while since I wrote test cases, but I recall using the assert*
> methods (assertEqual, assertTrue, etc.) instead of raising exceptions.
> Perhaps that's the issue?
Yes. I believe the methods all raise AssertionError on failure, and the
test methods are wrapped with try:.. except AssertionError as err:
if missing:
raise ValueError('invoices %r missing from batch' % missing)
should be "assertEqual(missing, [], 'invoices missing from batch')" and
if that fails, the non-empty list is printed along with the message.
--
Terry Jan Reedy
More information about the Python-list
mailing list