[TIP] Meta-test methods...

Robert Collins robertc at robertcollins.net
Fri Apr 24 17:30:26 PDT 2009

On Fri, 2009-04-24 at 20:11 -0400, laidler at stsci.edu wrote:
> So when I test, I want to make sure my tests probe most
> regions of the potential parameter space of input data. I use
> generated tests to run exactly the same test with varying
> inputs.

I use a form of dependency injection to do this: I write one test that
takes as parameters the stuff it needs to test. With unittest, I wrote a
little library 'testscenarios' to make it nice and easy to use. Hmm,
just remembered, I need to upload it to pypi.

Anyhow - https://launchpad.net/testscenarios is the homepage, README is

class TestFoo(TestCase):

    scenarios = [('zero', dict(start=0, end=0)),
                 ('-4K', dict(start=-4000, end=2))

    def test_something(self):

    def test_somethingelse(self):

and so on. I think this nicer than yielding inner functions - but its
arguably just a different spelling.

NB: to get the tests parameterised one needs either a loader hook or to
manually load (tests =
because of the lack of hook points for unittest. OTOH we should have
those in the nearish future anyway.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.idyll.org/pipermail/testing-in-python/attachments/20090425/9fcc3a43/attachment.pgp 

More information about the testing-in-python mailing list