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


Groups > comp.lang.python > #63749

Re: parametized unittest

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: parametized unittest
Date 2014-01-11 23:34 -0500
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-49C7C9.23343011012014@news.panix.com> (permalink)
References <c11a3b62-2053-4b6f-afda-d2df305f58e5@googlegroups.com> <mailman.5355.1389500996.18130.python-list@python.org>

Show all headers | View raw


In article <mailman.5355.1389500996.18130.python-list@python.org>,
 "W. Trevor King" <wking@tremily.us> wrote:

> 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].

Or, as yet another alternative, if you use nose, you can write test 
generators.

https://nose.readthedocs.org/en/latest/writing_tests.html#test-generators

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