diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-02-09 10:54:02 +0000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-02-09 10:54:02 +0000 |
| commit | 98dd8dd02e6a005266866ab1cb4a2ec00dce0193 (patch) | |
| tree | bf871584b80ed257e50f7a5b90bbfce4ceec51b7 /tests | |
| parent | 38b4adc6960d28483124509aa363dadbe8cc17a6 (diff) | |
Fixed #21892: RunPython no longer accepts strings
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_operations.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index 01f78b62b5..9d5ae91510 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -479,13 +479,11 @@ class OperationTests(MigrationTestBase): project_state = self.set_up_test_model("test_runpython") # Create the operation - operation = migrations.RunPython( - """ + def inner_method(models, schema_editor): Pony = models.get_model("test_runpython", "Pony") - Pony.objects.create(pink=2, weight=4.55) - Pony.objects.create(weight=1) - """, - ) + Pony.objects.create(pink=1, weight=3.55) + Pony.objects.create(weight=5) + operation = migrations.RunPython(inner_method) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards("test_runpython", new_state) @@ -498,16 +496,9 @@ 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) + # Now test we can't use a string + with self.assertRaises(ValueError): + operation = migrations.RunPython("print 'ahahaha'") class MigrateNothingRouter(object): |
