summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-09-25 16:10:43 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-09-25 16:10:43 +0100
commitfe9f342d8ceae96a03295e56ec743ed2e2e5fb51 (patch)
treef8d62ecaab2c5302a6f6a256d6cafbfc87848879 /tests
parent8a3e543f268ba027a631274d1cfe44db64ad9025 (diff)
Allow callables as the argument to RunPython
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_operations.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 1f247c1a97..db79e730e2 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -332,6 +332,15 @@ class OperationTests(MigrationTestBase):
# And test reversal fails
with self.assertRaises(NotImplementedError):
operation.database_backwards("test_runpython", None, new_state, project_state)
+ # Now test we can do it with a callable
+ def inner_method(models, schema_editor):
+ Pony = models.get_model("test_runpython", "Pony")
+ Pony.objects.create(pink=1, weight=3.55)
+ Pony.objects.create(weight=5)
+ operation = migrations.RunPython(inner_method)
+ with connection.schema_editor() as editor:
+ operation.database_forwards("test_runpython", editor, project_state, new_state)
+ self.assertEqual(project_state.render().get_model("test_runpython", "Pony").objects.count(), 4)
class MigrateNothingRouter(object):