Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68259
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: unittest weirdness |
| Date | 2014-03-11 23:36 -0400 |
| References | <mailman.8062.1394573210.18130.python-list@python.org> <lfo1qj$3m3$1@reader1.panix.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8072.1394595435.18130.python-list@python.org> (permalink) |
On 3/11/2014 6:13 PM, John Gordon wrote:
> In <mailman.8062.1394573210.18130.python-list@python.org> Ethan Furman <ethan@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-11 13:58 -0700
Re: unittest weirdness John Gordon <gordon@panix.com> - 2014-03-11 22:13 +0000
Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-11 15:29 -0700
Re: unittest weirdness Terry Reedy <tjreedy@udel.edu> - 2014-03-11 23:36 -0400
Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 03:03 -0700
Re: unittest weirdness Roy Smith <roy@panix.com> - 2014-03-12 09:44 -0400
Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 08:32 -0700
Re: unittest weirdness Roy Smith <roy@panix.com> - 2014-03-12 13:48 -0400
Re: unittest weirdness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-12 23:14 +0000
Re: unittest weirdness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-12 23:47 +0000
Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 17:31 -0700
Re: unittest weirdness Terry Reedy <tjreedy@udel.edu> - 2014-03-12 22:27 -0400
Re: unittest weirdness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-12 23:38 +0000
Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 17:36 -0700
csiph-web