south.management.commands: 18 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/south/management/commands/__init__.py

Stats: 0 executed, 12 missed, 6 excluded, 22 ignored

  1. # Common framework for syncdb actions
  2. import copy
  3. from django.core import management
  4. from django.conf import settings
  5. # Make sure the template loader cache is fixed _now_ (#448)
  6. import django.template.loaders.app_directories
  7. from south.hacks import hacks
  8. from south.management.commands.syncdb import Command as SyncCommand
  9. class MigrateAndSyncCommand(SyncCommand):
  10. """Used for situations where "syncdb" is called by test frameworks."""
  11. option_list = copy.deepcopy(SyncCommand.option_list)
  12. for opt in option_list:
  13. if "--migrate" == opt.get_opt_string():
  14. opt.default = True
  15. break
  16. def patch_for_test_db_setup():
  17. # Load the commands cache
  18. management.get_commands()
  19. # Repoint to the correct version of syncdb
  20. if hasattr(settings, "SOUTH_TESTS_MIGRATE") and not settings.SOUTH_TESTS_MIGRATE:
  21. # point at the core syncdb command when creating tests
  22. # tests should always be up to date with the most recent model structure
  23. management._commands['syncdb'] = 'django.core'
  24. else:
  25. management._commands['syncdb'] = MigrateAndSyncCommand()
  26. # Avoid flushing data migrations.
  27. # http://code.djangoproject.com/ticket/14661 introduced change that flushed custom
  28. # sql during the test database creation (thus flushing the data migrations).
  29. # we patch flush to be no-op during create_test_db, but still allow flushing
  30. # after each test for non-transactional backends.
  31. hacks.patch_flush_during_test_db_creation()