doit logo



Launchpad logo

Get doit at SourceForge.net. Fast, secure and Free Open Source software downloads

Environment setupΒΆ

Some tasks require some kind of environment setup/cleanup. Tasks have a list of “setup” objects. These objects can optionally define a “setup” and a “cleanup” method. Multiple tasks can share the same setup object.

  • the setup method will be executed before the first task that uses this object is executed
  • if no task that uses this object is called it is never setup
  • if the setup method has already been called it won’t be executed again for a different task
  • the cleanup method is executed after all tasks have finished their execution.

Example:

### task setup env. good for functional tests!

class SetupSample(object):
    def __init__(self, server):
        self.server = server

    def setup(self):
        # start server
        pass

    def cleanup(self):
        # stop server
        pass

setupX = SetupSample('x')
setupY = SetupSample('y')

def task_withenvX():
    for fin in ('a','b','c'):
        yield {'name': fin,
               'actions':['echo x'],
               'setup': [setupX]}

def task_withenvY():
    return {'actions':['echo y'],
            'setup': [setupY]}