[Twisted-Python] trial and setUpClass

Hi.
Just to be sure: setUpClass will be called *once* at the beginning of the TestCase?
Thanks Manlio Perillo

On 5/18/06, Manlio Perillo manlio_perillo@libero.it wrote:
Hi.
Just to be sure: setUpClass will be called *once* at the beginning of the TestCase?
Yes.

Manlio Perillo ha scritto:
Hi.
Just to be sure: setUpClass will be called *once* at the beginning of the TestCase?
Another question: there is a supported way to execute code before *all* TestCases run?
Now I simply execute a synchronous function before defining test cases.
Thanks and regards Manlio Perillo

On 5/18/06, Manlio Perillo manlio_perillo@libero.it wrote:
Manlio Perillo ha scritto:
Hi.
Just to be sure: setUpClass will be called *once* at the beginning of the TestCase?
Another question: there is a supported way to execute code before *all* TestCases run?
Now I simply execute a synchronous function before defining test cases.
No, there isn't.
What are you trying to do?
jml

Jonathan Lange ha scritto:
[...]
Another question: there is a supported way to execute code before *all* TestCases run?
Now I simply execute a synchronous function before defining test cases.
No, there isn't.
What are you trying to do?
Create some tables and functions on a PostgreSQL database.
Regards Manlio Perillo

On 5/18/06, Manlio Perillo manlio_perillo@libero.it wrote:
Jonathan Lange ha scritto:
[...]
Another question: there is a supported way to execute code before *all* TestCases run?
Now I simply execute a synchronous function before defining test cases.
No, there isn't.
What are you trying to do?
Create some tables and functions on a PostgreSQL database.
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:
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.
You could also refine the process so that setUpDB checks individual tables rather than the whole of your schema.
Hope this helps, jml

Jonathan Lange ha scritto:
On 5/18/06, Manlio Perillo manlio_perillo@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
participants (2)
-
Jonathan Lange
-
Manlio Perillo