Skip to content

Instantly share code, notes, and snippets.

@karolmajta
Created April 29, 2012 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karolmajta/2552837 to your computer and use it in GitHub Desktop.
Save karolmajta/2552837 to your computer and use it in GitHub Desktop.
terrain.py for running lettuce with django
import logging
from django.core.management import call_command
from lettuce import before, after
import yourprojec.test_settings
@before.all
def before_all():
logging.info("Setting up a test database...\n")
# Sync the test database
call_command('syncdb',
**{
'settings': yourproject.test_settings,
'interactive': False,
'verbosity': 0,
}
)
# Migrate test database with south
call_command('migrate',
**{
'settings': yourproject.test_settings,
'interactive': False,
'verbosity': 0,
}
)
@before.each_scenario
def before_scenario(scenario):
logging.info('Flushing test database...\n')
# Flush the database
call_command('flush',
**{
'settings': yourproject.test_settings,
'interactive': False,
'verbosity': 0,
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment