Dynamic generation of test cases for each input datum (was: Is it possible to get string from function?)

Roy Smith roy at panix.com
Thu Jan 16 00:09:08 EST 2014


In article <mailman.5569.1389848543.18130.python-list at python.org>,
 Ben Finney <ben+python at benfinney.id.au> wrote:

> Roy Smith <roy at panix.com> writes:
> 
> > I've got some unit tests that look like:
> >
> > class Foo(TestCase):
> >   def test_t1(self):
> >     RECEIPT = "some string"
> >
> >   def test_t2(self):
> >     RECEIPT = "some other string"
> >
> >   def test_t3(self):
> >     RECEIPT = "yet a third string"
> >
> > and so on.
> 
> That looks like a poorly defined class.
> 
> Are the test cases pretty much identical other than the data in those
> strings?

No, each test is quite different.  The only thing they have in common is 
they all involve a string representation of a transaction receipt.  I 
elided the actual test code in my example above because it wasn't 
relevant to my question.



More information about the Python-list mailing list