Skip to content

Instantly share code, notes, and snippets.

@c-rhodes
Forked from NotSqrt/settings_test_snippet.py
Last active August 29, 2015 14:14
Show Gist options
  • Save c-rhodes/cebe9d4619125949dff8 to your computer and use it in GitHub Desktop.
Save c-rhodes/cebe9d4619125949dff8 to your computer and use it in GitHub Desktop.
A solution to avoid migrations when testing in Django 1.7, the config is set in manage.py so no environment variables have to be set
# settings.py
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
# This would be a subclass of a settings class, in my case Local, i.e. class UnitTests(Local):
class UnitTests:
MIGRATION_MODULES = DisableMigrations()
# Add this to manage.py
if 'test' in sys.argv:
os.environ['DJANGO_CONFIGURATION'] = 'UnitTests'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment