Skip to content

Instantly share code, notes, and snippets.

@scott-coates
Created August 29, 2013 16:51
Show Gist options
  • Save scott-coates/6380588 to your computer and use it in GitHub Desktop.
Save scott-coates/6380588 to your computer and use it in GitHub Desktop.
If you are running some django tests in an environment where you want to force south to run, you can use this gist. This was taken from the pycharm test runner.
from django.core import management
from django.conf import settings
def enable_south_migrations():
management.get_commands()
if hasattr(settings, "SOUTH_TESTS_MIGRATE") and not settings.SOUTH_TESTS_MIGRATE:
# point at the core syncdb command when creating tests
# tests should always be up to date with the most recent model structure
management._commands['syncdb'] = 'django.core'
elif 'south' in settings.INSTALLED_APPS:
try:
from south.management.commands import MigrateAndSyncCommand
management._commands['syncdb'] = MigrateAndSyncCommand()
from south.hacks import hacks
if hasattr(hacks, "patch_flush_during_test_db_creation"):
hacks.patch_flush_during_test_db_creation()
except ImportError:
management._commands['syncdb'] = 'django.core'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment