Created
April 29, 2012 19:22
-
-
Save karolmajta/2552837 to your computer and use it in GitHub Desktop.
terrain.py for running lettuce with django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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