Creating unit tests on the fly

Roy Smith roy at
Sat Apr 9 04:02:57 CEST 2011

In article <87fwpse4zt.fsf at>,
 Ben Finney <ben+python at> wrote:

> Raymond Hettinger <python at> writes:
> > I think you're going to need a queue of tests, with your own test
> > runner consuming the queue, and your on-the-fly test creator running
> > as a producer thread.
> I have found the ‘testscenarios’ library very useful for this: bind a
> sequence of (name, dict) tuples to the test case class, and each tuple
> represents a scenario of data fixtures that will be applied to every
> test case function in the class.
>     <URL:>
> You (the OP) will also find the ‘testing-in-python’ discussion forum
> <URL:> useful for this
> topic.

That link doesn't work, I assume you meant

This is interesting, and a bunch to absorb.  Thanks.  It might be what 
I'm looking for.  For the moment, I'm running the discovery then doing 
something like

    class_name = 'Test_DiscoveredRoute_%s' % cleaned_route_name
    g = globals()
    g[class_name] = type(class_name, bases, new_dict)

on each discovered route, and calling unittest.main() after I'm done 
doing all that.  It's not quite what I need however, so something like 
testscenarios or raymondh's test queue idea might be where this needs to 

More information about the Python-list mailing list