[Twisted-Python] Deferreds and Trial -- getting my timing right

Greetings, I've paused development to bring my unittests up to date, and have hit another snag. I am under the impression that no real work should be done in my factory's init, so I have a bunch of routines that load data from a DB in startFactory() (they all return deferreds from adbapi). I'm not sure when startFactory() runs, but I know it's definitely not running before my tests fire. I'm curious: do I need to move my data loading back into init, save the deferred and return that deferred from setUp to have all my pre-loading complete before my tests run? When does startFactory() actually fire? Thanks, Brendon Colby

On Wed, 31 Oct 2007 11:13:08 -0500, Brendon Colby <brendoncolby@gmail.com> wrote:
Greetings,
I've paused development to bring my unittests up to date, and have hit another snag. I am under the impression that no real work should be done in my factory's init, so I have a bunch of routines that load data from a DB in startFactory() (they all return deferreds from adbapi). I'm not sure when startFactory() runs, but I know it's definitely not running before my tests fire. I'm curious: do I need to move my data loading back into init, save the deferred and return that deferred from setUp to have all my pre-loading complete before my tests run? When does startFactory() actually fire?
When your factory begins listening on its first port. f = YourFactory() reactor.listenTCP(0, f) # <- here reactor.run() Jean-Paul

On 10/31/07, Jean-Paul Calderone <exarkun@divmod.com> wrote:
When your factory begins listening on its first port.
f = YourFactory() reactor.listenTCP(0, f) # <- here reactor.run()
Jean-Paul
So what do I need to do in my unittests to get this to work? I'm using a FileWrapper now to mock this up, so I never run listenTCP() of course. Brendon

On Wed, 31 Oct 2007 12:01:06 -0500, Brendon Colby <brendoncolby@gmail.com> wrote:
On 10/31/07, Jean-Paul Calderone <exarkun@divmod.com> wrote:
When your factory begins listening on its first port.
f = YourFactory() reactor.listenTCP(0, f) # <- here reactor.run()
Jean-Paul
So what do I need to do in my unittests to get this to work? I'm using a FileWrapper now to mock this up, so I never run listenTCP() of course.
I dunno. I can't remember the last time I put any code in a factory's __init__ or its startFactory method. Maybe you could call the startFactory method in your test? Jean-Paul

On 10/31/07, Jean-Paul Calderone <exarkun@divmod.com> wrote:
I dunno. I can't remember the last time I put any code in a factory's __init__ or its startFactory method. Maybe you could call the startFactory method in your test?
Hrmm...good idea. I think I know what I need to do now. Thanks for the pointer. Brendon
participants (2)
-
Brendon Colby
-
Jean-Paul Calderone