Andrew Godwin avatar Andrew Godwin committed 3602a98

Fix syncdb-migrateyness

Comments (0)

Files changed (4)

south/management/commands/__init__.py

+
+# Common framework for syncdb actions
+
+import copy
+
+from django.core import management
+from django.conf import settings
+
+from south.management.commands.syncdb import Command as SyncCommand
+
+class MigrateAndSyncCommand(SyncCommand):
+    """Used for situations where "syncdb" is called by test frameworks."""
+    
+    option_list = copy.deepcopy(SyncCommand.option_list)
+    
+    for opt in option_list:
+        if "--migrate" == opt.get_opt_string():
+            opt.default = True
+            break
+
+def patch_for_test_db_setup():
+    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'
+    else:
+        management._commands['syncdb'] = MigrateAndSyncCommand()

south/management/commands/syncdb.py

             if verbosity:
                 print "\nNot synced (use migrations):\n - %s" % "\n - ".join(apps_migrated)
                 print "(use ./manage.py migrate to migrate these)"
-
-class MigrateAndSyncCommand(Command):
-    """Used for situations where "syncdb" is called by test frameworks."""
-    option_list = Command.option_list
-    for opt in option_list:
-        if "--migrate" == opt.get_opt_string():
-            opt.default = True
-            break
-
-def patch_for_test_db_setup():
-        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'
-        else:
-            management._commands['syncdb'] = MigrateAndSyncCommand()

south/management/commands/test.py

 from django.core.management.commands import test
-import south.management.commands.syncdb
+
+from south.management.commands import patch_for_test_db_setup
 
 class Command(test.Command):
     def handle(self, *args, **kwargs):
-        south.management.commands.syncdb.patch_for_test_db_setup()
+        patch_for_test_db_setup()
         super(Command, self).handle(*args, **kwargs)

south/management/commands/testserver.py

 from django.core.management.commands import testserver
-import south.management.commands.syncdb
+
+from south.management.commands import patch_for_test_db_setup
 
 class Command(testserver.Command):
     def handle(self, *args, **kwargs):
-        south.management.commands.syncdb.patch_for_test_db_setup()
+        patch_for_test_db_setup()
         super(Command, self).handle(*args, **kwargs)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.