Great, works a treat. Thanks -----Original Message----- From: Jim Sizelove [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 15, 2004 11:28 AM To: [EMAIL PROTECTED] Subject: Re: Dynamically passing variables to unittest
Tom Haddon wrote: > Hi Peter, > > Yeah, you're right, the term "ConnectString" is a little confusing. Perhaps I > should change that. > > Here's a valid call to DB: > > conn=DB.DB('pg','test','localhost',5432,'test','test') > > In the context of this unittest, a valid syntax would be (except that this > unittest would fail, as this is a "good" connection: > > self.assertRaises(DB.InvalidConnectString, > DB.DB,'pg','test','localhost',5432,'test','test') > You can try something like this (not tested): >>> InvalidStrings=(['pg','test','localhost','5432','test','test'], ['pg','test','local',5432,'test','test']) >>> for S in InvalidStrings: ... self.assertRaises(DB.InvalidConnectString, DB.DB, *S) ... Here the * operator unpacks a sequence when passed in to a function that is expecting positional arguments. See the Python Tutorial, 4.7.4 Unpacking Argument Lists for a better explanation. http://docs.python.org/tut/node6.html hth, Jim -- http://mail.python.org/mailman/listinfo/python-list