Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63748

Re: parametized unittest

Date 2014-01-11 20:28 -0800
From "W. Trevor King" <wking@tremily.us>
Subject Re: parametized unittest
References <c11a3b62-2053-4b6f-afda-d2df305f58e5@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.5355.1389500996.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote:
> I'm finding it hard to use unittest in a for loop.  Perhaps something like:
> 
> for val in range(25):
>   self.assertEqual(val,5,"not equal)
> 
> The loop will break after the first failure.  Anyone have a good
> approach for this?  please advise.

If Python 3.4 is an option, you can stick to the standard library and
use subtests [1].

Cheers,
Trevor

[1]: http://docs.python.org/3.4/library/unittest.html#distinguishing-test-iterations-using-subtests

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

parametized unittest CraftyTech <hmmedina@gmail.com> - 2014-01-11 20:00 -0800
  Re: parametized unittest Ben Finney <ben+python@benfinney.id.au> - 2014-01-12 15:22 +1100
  Re: parametized unittest "W. Trevor King" <wking@tremily.us> - 2014-01-11 20:28 -0800
    Re: parametized unittest Roy Smith <roy@panix.com> - 2014-01-11 23:34 -0500
      Re: parametized unittest CraftyTech <hmmedina@gmail.com> - 2014-01-12 08:57 -0800

csiph-web