pyUnit and dynamic test functions

Kent Johnson kent at kentsjohnson.com
Wed Dec 21 17:38:34 EST 2005


Sakcee wrote:
> Hi
> 
> I am trying to use pyUnit to create a framework for testing functions
> 
> I am reading function name, expected output,  from a text file.

Can you show a sample of what the text file might look like, and what tests you want to 
generate from it?

> and in python generating dynamic test functions
> something like this
> 
> 
> class getUsStatesTest( unittest.TestCase ):
> 
>     self.setUp =  lambda  : function_call
>     self.testReturnVal =  lambda  : self.assertEqual( fileInput,
> function_returnedVals )
>     self.testLength    =  lambda  : self.assertEqual( len(returnedVals)
> , len(inp) )

I don't understand the above at all. What do function_call, function_returnedVals, 
returnedVals and inp refer to? What is the point of the lambdas and the assignment to 
attributes of (undefined) self?

Kent



More information about the Python-list mailing list