[Twisted-Python] trial and setUpClass
Manlio Perillo
manlio_perillo at libero.it
Fri May 19 13:09:52 MDT 2006
Jonathan Lange ha scritto:
> On 5/18/06, Manlio Perillo <manlio_perillo at libero.it> wrote:
>> Jonathan Lange ha scritto:
>> > [...]
>> >> Another question: there is a supported way to execute code before
>> *all*
>> >> TestCases run?
> [...]
> In that case, here's what I'd do. I'd create a couple of top-level
> functions (maybe methods in a TestCase subclass -- who knows?), like
> this:
>
Ok, I already use a common subclass.
> def checkDB():
> # check the database is configured properly.
> # return False if it needs to be restored
>
> def setUpDB():
> if not checkDB():
> # drop & create a bunch of tables
>
> I'd then whack a call to setUpDB() in my setUp (_not_ setUpClass) for
> every test case that needed to use the database. That way, I'd know
> that the data was always correct, and I wouldn't be reconfiguring the
> database for every single test.
>
Thanks, good idea.
For now, however, I simply use os.system and os.popen with psgl.
Regards Manlio Perillo
More information about the Twisted-Python
mailing list